UI & Customization

Localization (l10n)

Localizations controller singleton, ARB translation files, and hand-edited class mappings.

Overview

Wiltkey client UI supports multi-language translations (English, German, French, Hungarian, Polish, Swedish, and Chinese). However, unlike standard Flutter projects that run code generation scripts to compile translation files dynamically, Wiltkey disables the code generation builder. The compiled localization classes are checked directly into the codebase and must be edited manually.

How it Works

  1. Locale Controller: The active language is coordinated by LocaleController, a ChangeNotifier singleton. On startup, it calls WiltkeyPersistence.loadLocale to retrieve the language code (saved under SharedPreferences key wk_locale). If the value is null or 'system', the app falls back to the system locale.
  2. Translation files directory: All files reside in:
    wiltkey_client/lib/l10n/
  3. Hand-Edited Mappings: Adding a translation key requires editing the translation ARB files (e.g. app_en.arb) AND hand-editing the compiled localization classes (e.g. app_localizations.dart and app_localizations_en.dart) to add the corresponding Dart methods and getter overrides.

Key Files & Symbols

File Path Symbol Name Description
lib/core/localization/locale_controller.dart LocaleController Coordinates locale changes, notifies UI rebuilds, and persists selections.
lib/l10n/app_localizations.dart AppLocalizations Hand-edited abstract class describing all translation getters and delegates.
lib/l10n/app_en.arb app_en.arb Resource Bundle translation keys file for the English locale.

Gotchas & Edge Cases

⚠️ DO NOT RUN GEN-L10N
Running the standard Flutter code generation script (flutter gen-l10n) will overwrite and discard all manual layout overrides and adjustments made inside the app_localizations_*.dart files. Translations must only be edited by hand.