Translation Architecture
Translations are stored in JSON files:Translation File Structure
Translation files use nested objects:Adding a Language
Using Translations in Components
In Templates
Wrap your template in a Transloco container:In Component Code
Inject TranslocoService:Structural Directive
For components with TranslocoModule imported:Translation Keys Manager
Jet includes Transloco Keys Manager for maintaining translations.Extract Translation Keys
Automatically extract keys from templates and TypeScript:t('key')in templatesmarker('key')in TypeScripttranslate('key')in TypeScript
Find Missing Keys
Find missing or unused translation keys:- Keys used in code but missing from translation files
- Keys in translation files but not used in code
Using the Marker Function
For keys defined in TypeScript (like constants):marker function doesn’t translate at definition time—it just marks the key for extraction.
Changing the Default Language
Removing a Language
Remove from language options
Remove the language entry from
src/app/constants/language-options.constant.ts.RTL Language Support
Configuring RTL
For RTL languages (like Arabic), setdirectionality: 'rtl':
- Sets
dir="rtl"on the document - Flips layouts using CSS logical properties
- Adjusts safe areas for notched devices
- Mirrors animations
Testing RTL
- Switch to Arabic in Settings
- Verify layout flips correctly
- Check text alignment
- Test navigation and animations
Translation Best Practices
Use nested keys for organization
Use nested keys for organization
Organize translations by component or feature:
Use component selector as key prefix
Use component selector as key prefix
Name translation keys after component selectors:
Include context in key names
Include context in key names
Make keys descriptive:
Use parameters for dynamic content
Use parameters for dynamic content
Use interpolation for dynamic values:Usage:
Keep translations flat when possible
Keep translations flat when possible
Avoid deep nesting unless necessary:
Run i18n:find regularly
Run i18n:find regularly
Regularly check for missing or unused keys:Clean up unused keys to keep translation files maintainable.
Translation Optimization
Jet optimizes translations at build time using@jsverse/transloco-optimize.
Post-build Optimization
The build process runs:- Removes unused translation keys
- Minifies translation files
- Reduces bundle size
Manual Optimization
Optimization runs automatically duringnpm run build, but you can also:
- Build the project
- Run the optimization script manually
- Verify optimized files in
dist/jet/browser/i18n/