Frontend Localization¶
This section documents internationalization and localization patterns in the Catalyst Voices frontend application.
Overview¶
The application uses ARB (Application Resource Bundle) files with Flutter's
flutter_localizations for type-safe, multi-language support.
ARB Files¶
ARB files are JSON-based translation files located in:
packages/internal/catalyst_voices_localization/lib/l10n/
File Structure¶
{
"@@locale": "en",
"keyName": "Translation value",
"@keyName": {
"description": "Description for translators"
}
}
Template File¶
intl_en.arb serves as the template:
- All new strings added here first
- English is the base language
- Used to generate type-safe accessors
Code Generation¶
Configuration¶
l10n.yaml:
arb-dir: lib/l10n
output-dir: lib/generated/
template-arb-file: intl_en.arb
output-localization-file: catalyst_voices_localizations.dart
output-class: VoicesLocalizations
preferred-supported-locales: [en]
use-deferred-loading: true
Generation¶
Generates VoicesLocalizations class with type-safe accessors.
Usage¶
In Widgets¶
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
Text(context.l10n.loginScreenPasswordLabelText)
Locale Resolution¶
Flutter automatically resolves locale based on:
- Device locale
- User preferences
- Supported locales
Translation Workflow¶
Adding New Strings¶
- Add to
intl_en.arb:
{
"newFeatureTitle": "New Feature",
"@newFeatureTitle": {
"description": "Title for new feature"
}
}
- Generate localizations:
-
Add translations to locale files (e.g.,
intl_es.arb) -
Use in code:
Translation Management¶
Cleaning Unused Keys¶
Removes translation keys not used in code.
Sorting Keys¶
Sorts keys alphabetically in ARB files.
Validation¶
Validates that files are clean and sorted (useful for CI).
Supported Locales¶
Locales must be configured in:
l10n.yaml(Flutter)ios/Runner/Info.plist(iOS -CFBundleLocalizations)- Android manifest (Android)
Best Practices¶
- Always add to template first: Add new strings to
intl_en.arb - Include descriptions: Help translators understand context
- Use descriptive keys: Clear, semantic key names
- Keep in sync: Maintain translations across all locales
- Validate in CI: Run
--checkin continuous integration - Use deferred loading: Improves initial load performance