-
Notifications
You must be signed in to change notification settings - Fork 4
I18n Internationalization
Benjamin Eder edited this page Jan 6, 2019
·
1 revision
Internationalization is pretty done pretty simple within the app. The localized strings are stored within a map for each language. All translations are done in the AppLocalizations class.
When you want to add new localized values just add them in the class and provide a getter.
We are adding a new localized value for the string "Hello World":
// We are in the AppLocalizations class
/// German localized values.
static const Map<String, String> _deLocalizations = {
// more localized values...
"hello_world": "Hallo Welt",
}
/// English localized values.
static const Map<String, String> _enLocalizations = {
// more localized values...
"hello_world": "Hello World",
}
// A bunch of getters for localized values...
String get helloWorld => _get("hello_world");
Aaaaand you're done!
In order to use the localized values in the UI just call AppLocalizations.of(context).helloWorld where you need it.