i18n_extension_core library

Classes

ConstTranslations
The ConstTranslations constructor 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.
DefaultLocale
To set the default locale, use this class:
TranslatedString
This class represents missing translations. They are recorded in Translations.missingTranslations and Translations.recordMissingKeys.
Translations<T>
You may use this class to provide the translated strings.
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

convertToIntegerModifier(Object? modifierObj) int
See rules stated in localizePlural's documentation. IMPORTANT: This function is visible for testing purposes only.
localize(String key, Translations 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(String key, Translations 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(String text, List<Object> params) String
Does an sprintf on the text with the params. This is implemented with the sprintf package: https://pub.flutter-io.cn/packages/sprintf
localizePlural(Object? modifier, String key, Translations 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, String key, Translations 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(String key) String
Function recordMissingKey simply records the given key as a missing translation with unknown locale. It returns the same key provided, unaffected.