name: GetX Localization Standard description: Standards for GetX-based multi-language (locale_key + lang_*.dart). Invoke when generating a new page/feature or adding any user-facing text. metadata: labels: [localization, getx, translations, i18n, multi-language] triggers: files: ['lib//locale_key.dart', 'lib//lang_*.dart', 'lib//app_translations.dart', 'lib//app.dart'] keywords: [locale_key, lang_en, lang_ja, translate, translation, .tr, GetMaterialApp, Translations]
GetX Localization Standard
Priority: P1 (HIGH)
All user-facing text MUST be localized via GetX Translations using locale_key.dart + lang_*.dart.
Core Rules (When generating a page)
1) locale_key.dart MUST be updated
- Add every new key used by the new page.
- Keys MUST be stable and semantic.
- Key naming format:
<feature>_<screen>_<element>insnake_case(e.g.customer_detail_title).
2) ALL language files MUST be updated
Whenever a new key is added, you MUST update:
lang_en.dartlang_ja.dart- Any existing
lang_*.dartlanguages in the project
No language is allowed to miss keys.
3) UI MUST use .tr (no raw strings)
- Always write:
LocaleKey.someKey.tr - Never hardcode labels like
'Home','ホーム','Trang chủ'in widgets.
Project Implementation (Source of Truth)
- Keys:
lib/src/core/localization/locale_key.dart - Translations:
lib/src/core/localization/lang_en.dartlib/src/core/localization/lang_ja.dartlib/src/core/localization/lang_vi.dart
- Registry:
lib/src/core/localization/app_translations.dart - App wiring:
lib/src/app.dartusesGetMaterialApp.router(...)withtranslations,supportedLocales,fallbackLocale.
Adding a New Language
- Create
lang_<code>.dart(e.g.lang_ko.dart) asMap<String, String>. - Register it in
AppTranslations.keysusing<lang>_<COUNTRY>(e.g.ko_KR). - Add the corresponding
Locale('<lang>', '<COUNTRY>')tosupportedLocales. - Ensure every key in
locale_key.dartexists in the new language map.
Quality Gates (Reject if violated)
- Any new page introduces raw strings in UI.
locale_key.dartis changed but anylang_*.dartmisses the same keys.- Key names are generic or unstable (e.g.
title1,text_2, random ids).