Skip to content

Localization & Translation

DashLearn features resilient multi-language support built using GetX Translations. The project structure uses Mixins and Part files to keep the translation logic clean and modular.

The app currently supports 10 languages out of the box:

  • English (en_US)
  • Bangla (bn_BD)
  • Arabic (ar_SA)
  • German (de_DE)
  • Spanish (es_ES)
  • French (fr_FR)
  • Hindi (hi_IN)
  • Italian (it_IT)
  • Portuguese (pt_BR)
  • Turkish (tr_TR)

Translations are located in lib/app/translations/.

  • app_translations.dart: The main entry point that aggregates all languages.
  • _en.dart, _es.dart, etc.: Individual language files defined as parts.

To add a new language (e.g., Japanese ja_JP), follow these steps:

Create a new file lib/app/translations/_ja.dart. Define a mixin that implements your translations:

lib/app/translations/_ja.dart
part of 'app_translations.dart';
mixin JaKeys on Translations {
final jaKeys = <String, String>{
'language': '言語',
'details': '詳細',
// ... add all required keys
};
}

Open lib/app/translations/app_translations.dart and register your new mixin.

  1. Add Part Directive:

    part '_tr.dart';
    part '_ja.dart'; // Add this
  2. Add Mixin:

    class AppTranslations extends Translations
    with EnKeys, ..., TrKeys, JaKeys { // Add JaKeys
  3. Add to Keys Map:

    @override
    Map<String, Map<String, String>> get keys => {
    'en_US': enKeys,
    'ja_JP': jaKeys, // Register specific locale
    };

To change the app’s default language (fallback), update your GetMaterialApp configuration in main.dart or app_pages.dart (wherever initialized):

GetMaterialApp(
// ...
locale: Locale('ja', 'JP'),
fallbackLocale: Locale('en', 'US'),
);