```
## Key Transformations
- **Translation keys**: Converted from camelCase/snake_case to kebab-case IDs
- `camelCaseKey` → `@@camel-case-key`
- `snake_case_key` → `@@snake-case-key`
- `dotted.key.name` → `@@dotted-key-name`
- **Interpolations**: Wrapped in `` elements with `i18n` attributes
- **Attribute bindings**: Converted to `i18n-{attribute}` attributes
- **Parameters**: Currently preserved as-is (may need manual review)
## Output Files
When using `--output` option, the tool generates:
- **Analysis reports**: Markdown files with usage statistics
- **Migration reports**: Detailed change logs with before/after comparisons
- **Backup files**: Original files with `.backup` extension
- **Comparison reports**: Side-by-side before/after views
## Error Handling
The tool includes comprehensive error handling:
- **File not found**: Graceful handling of missing files
- **Parse errors**: Detailed error messages for malformed templates
- **Validation failures**: Automatic rollback on transformation errors
- **Backup creation**: Automatic backup before destructive operations
## Testing
Run the CLI tests:
```bash
npm test -- templates/cli.spec.ts
```
The test suite covers:
- Analysis functionality
- Dry-run migration
- Actual file migration
- Validation of results
- Comparison report generation
- Error scenarios
## Integration
This tool is part of the larger Angular i18n migration suite. Use it in conjunction with:
- **TypeScript migrator**: For migrating `I18nService.t()` calls to `$localize`
- **Build system updates**: For configuring Angular's i18n build process
- **Translation file conversion**: For converting JSON to XLIFF format
## Troubleshooting
### Common Issues
1. **No files found**: Check your pattern and current directory
2. **Permission errors**: Ensure write permissions for target files
3. **Parse errors**: Check for malformed HTML in templates
4. **Validation failures**: Review transformation accuracy
### Debug Mode
Use `--verbose` flag for detailed logging:
```bash
npm run template-migrate -- --pattern "**/*.html" --verbose --dry-run
```
This will show:
- Files being processed
- Transformations being applied
- Validation results
- Error details