Localization
Priority: P1 (STANDARD)
Consistent multi-language support using easy_localization.
Format Selection
- CSV (Recommended for teams with translators): Google Sheets compatibility via
sheet_loader_localization. Store inassets/langs/. - JSON (Developer-friendly): Nested structure support with IDE validation. Store in
assets/translations/.
Structure
# CSV Format (Google Sheets workflow)
assets/langs/langs.csv
# OR JSON Format (nested keys)
assets/translations/
├── en.json
└── vi.json
Implementation Workflow
- Initialize — Call
await EasyLocalization.ensureInitialized()beforerunApp. - Wrap root — Wrap the app with
EasyLocalizationwidget specifying supported locales and path. - Translate strings — Use
.tr()extension on keys (e.g.,'welcome'.tr()). - Switch locale — Change via
context.setLocale(Locale('vi')). - Handle plurals — Use
plural()for quantity-dependent strings. - Sync translations — Use
sheet_loader_localizationto auto-generate CSV/JSON from Google Sheets.
Bootstrap & Usage Examples
See implementation examples for bootstrap setup and translation usage patterns.
Anti-Patterns
- ❌ Hardcoded strings in UI — always use translation keys
- ❌ Using
Localizations.ofmanually — useeasy_localization.tr()extension - ❌ Mismatched keys across locale files — keep keys identical in all locales
Reference & Examples
For setup and Google Sheets automation: See references/REFERENCE.md.
Related Topics
idiomatic-flutter | widgets