EZ Flutter supports the usage of multiple languages for a app.


Translation is handled by different .json files that contain the translation for each language supported by the app. The translation files are automatically loaded by the EzRunner at startup. Create a .json file with the pattern locale_$loacle.json under the locale folder for each supported language.

Example: locale_en.json && locale_de.json

  "SOME_MESSAGE": "This is some message!"
  "SOME_MESSAGE": "Dies ist eine Nachricht!"


Define supported languages

Add all supported locales to the EzRunner at startup., [Locale('en'), Locale('de'), Locale('en')]);

Access translation

Access the translation within your app via the EzTranslator.


Use placeholder in your translation

The translation feature offers the possibility to use placeholders inside your translations. Add placeholders to your translation that start with a $ sign.

  "WELCOME_MESSAGE": "Hello $fname $lname, how are you?"
  "WELCOME_MESSAGE": "Hallo $fname $lname, wie geht es dir?"

Add the optional parameter replace to the text() method.

EzTranslator.of(context).text("WELCOME_MESSAGE", replace: {"fname": "Jon", "lname": "Doe"});

Update translation files for missing translation labels

EZ Flutter provides an easy to use package for automatically detecting translations within your code and updating the extisting translation files at /locales with the missing labels.

dev_dependencies: ez_flutter_translation_generator: ^1.0.1

Run the following command in your command line:

flutter pub run build_runner build