Features
Internationalization (i18n)
10/11/2026
Add and switch Flutter localizations with ARB files and Riverpod preferences.
Current setup
The template uses Flutter's generated localization system:
l10n/app_en.arbl10n/app_id.arbl10n/generated/app_localizations.dartl10n.yaml
SupportedLocales also exposes a system sentinel so users can follow the device language. English and Indonesian are the bundled locales.
Selecting a language
user_preferences_provider.dart persists the selected code through SharedPreferences. The Account sync service sends the language to PUT /api/v1/app/preferences; Guest mode keeps it local. The localization_provider.dart maps the stored code to Locale/system behavior.
Use generated localization access in widgets:
final l10n = AppLocalizations.of(context)!;
Text(l10n.settings);Add a locale or key
- Add the key/value to both
l10n/app_en.arbandl10n/app_id.arb(or add a new ARB locale intentionally). - Keep placeholders and descriptions consistent.
- Run
flutter gen-l10n(or the IDE's Flutter localization generation) to refreshl10n/generated/. - Use the generated
AppLocalizationsgetter; do not hardcode user-facing strings. - Test system language, explicit language, fallback, and persisted preference behavior.
Relevant files
l10n.yamll10n/app_*.arbl10n/generated/providers/localization_provider.dartproviders/user_preferences_provider.dartlib/main.dart
