i18n_extension library

Classes

ConstTranslations<TKEY extends String, TRANbyLOCALE extends Map<StringLocale, StringTranslated>, TRANbyTKEY extends Map<TKEY, StringTranslated>, ADDEDMAP extends TRANbyLOCALE>
The ConstTranslations class allows you to define the translations as a const object, all at once. This not only is a little bit more efficient, but it's also better for "hot reload", since a const variable will respond to hot reloads, while final variables will not.
I18n
Wrap your widget tree with the I18n widget. This will translate your strings to the current system locale:
TranslatedString
This class represents missing translations. They are recorded in Translations.missingTranslations and Translations.recordMissingKeys.
Translations<TKEY, TRANbyLOCALE extends Map<StringLocale, StringTranslated>, TRANbyTKEY extends Map<TKEY, StringTranslated>, ADDEDMAP>
A Translations object is where you provide the translated strings. Given a "translation-key", it returns a map of translations: { locale : translated strings }. The translation-key may be the string itself that you want to translate, or an identifier.
TranslationsException
All translation exceptions are of type TranslationsException.

Extensions

Localization on String
String extension which allows you to add plural modifiers to a string.

Functions

localize(Object? key, Translations<dynamic, Map<StringLocale, StringTranslated>, Map<dynamic, StringTranslated>, dynamic> translations, {String? locale}) String
Use the localize method to localize a "translatable string" to the given locale. You must provide the key (which is usually the string you want to translate) and the translations object which holds the translations.
localizeAllVersions(Object? key, Translations<dynamic, Map<StringLocale, StringTranslated>, Map<dynamic, StringTranslated>, dynamic> translations, {String? locale}) Map<String?, String>
Use the localizeAllVersions method to return a Map of all translated strings, where modifiers are the keys. In special, the unversioned text is indexed with a null key.
localizeFill(Object? text, List<Object> params) String
Does an sprintf on the text with the params. This is implemented with the sprintf package: https://pub.dev/packages/sprintf
localizePlural(Object? modifier, Object? key, Translations<dynamic, Map<StringLocale, StringTranslated>, Map<dynamic, StringTranslated>, dynamic> translations, {String? locale}) String
Returns the translated version for the plural modifier. After getting the version, substring %d will be replaced with the modifier.
localizeVersion(Object modifier, Object? key, Translations<dynamic, Map<StringLocale, StringTranslated>, Map<dynamic, StringTranslated>, dynamic> translations, {String? locale}) String
Use the localizeVersion method to localize a "translatable string" to the given locale. You must provide the key (which is usually the string you want to translate), a modifier, and the translations object which holds the translations.
recordMissingKey(Object? key) String
Function recordMissingKey simply records the given key as a missing translation with unknown locale. It returns the same key provided, unaffected.