2.2 KiB
2.2 KiB
Localization Guidelines
This app uses Flutter's gen-l10n with ARB files in lib/l10n.
- Source language:
en(lib/l10n/app_en.arb) - Translations:
lib/l10n/app_<lang>.arb(e.g.,app_de.arb) - Generated Dart:
lib/l10n/app_localizations*.dart(generated by Flutter)
Adding New Strings
- Edit
lib/l10n/app_en.arband add a key with a clear description meta entry.- Example:
"greeting": "Hello, {name}!", "@greeting": { "description": "Friendly greeting with user name.", "placeholders": { "name": { "type": "String", "example": "Alex" } } } - Run
flutter gen-l10nor justflutter runto regenerate localizations. - Use it in code:
AppLocalizations.of(context)!.greeting(name).
Placeholders and ICU
- Always declare placeholders under the
@key.placeholdersblock withtypeand optionalexample. - Use ICU for plurals/select:
"itemsCount": "{count, plural, =0{No items} one{1 item} other{{count} items}}", "@itemsCount": { "placeholders": { "count": { "type": "int" } } }
Punctuation and Style
- Prefer typographic ellipsis
…over.... - Keep capitalization consistent across locales.
- Avoid embedding brand names in placeholders; keep them literal in strings.
Weblate
This repository includes weblate.yaml to help auto-configure Weblate.
- File mask:
lib/l10n/app_*.arb - Template:
lib/l10n/app_en.arb - New language file path:
lib/l10n/app_{language}.arb - Monolingual:
true - Base language:
en
Recommended Weblate add-ons:
- “JSON/ARB reformat” to keep formatting stable.
- “String freeze” (when preparing releases).
- Checks for placeholders to ensure
{name},{count}, etc. are preserved.
Generated Files Policy
- Generated localization Dart files are NOT committed. They are ignored via
.gitignoreand generated during CI/build. - Run
flutter gen-l10nlocally when you need IDE completion, or rely onflutter runwhich generates them automatically.
Common Tasks
- Regenerate after ARB edits:
flutter gen-l10n --arb-dir=lib/l10n --output-dir=lib/l10n --template-arb-file=app_en.arb --output-localization-file=app_localizations.dart
- Validate:
flutter analyze