WayFar
Search…
Internationalization
WayFar template integrates easy_localization package that enables localization feature and right to left support. (https://pub.dev/packages/easy_localization)

Configuration

To support a new locale, head over to the file locales.dart under the folder lib/core/localization and use AppLanguage class to configure the language:
locales.dart
1
final languages = [
2
AppLanguage("en","US","English", isDefault: true),
3
AppLanguage("fr","FR","French"),
4
AppLanguage("ar","AE","العربية"),
5
//Add languages here
6
// AppLanguage(languageCode, countryCode, displayName, isDefault)
7
];
Copied!

Translations resources

Once the configuration is done, you have to add the corresponding resource file in the folder lib/translations:
The file naming must respect this format : [languageCode]-[countryCode].json

Translate

To translate text use the main function tr() :
1
Text('title').tr() //Text widget
2
3
print('title'.tr()); //String
4
5
var title = tr('title') //Static function
Copied!
easy_localization package has also advances usages, visit the official doc to see more.