Localison class

A utility class to load localization texts from a JSON resource file.


Localison(Locale locale, {String separator, Map<LocalisonQuantity, int> quantities})
Instantiates a new Localison instance using the specified locale. [...]


hashCode int
The hash code for this object. [...]
read-only, inherited
locale Locale
The Locale currently in use in this instance.
quantities Map<LocalisonQuantity, int>
Rules to represent a quantity that doesn't follow the plural rules of locale's language.
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
separator String
Separator character between a key name, gender value, and plural count value.


contains(String key, {num count, LocalisonGender gender, bool quantify}) bool
Returns true if the passed key is part of the localized keys, false otherwise. [...]
load({bool cachable}) Future<void>
Asynchronously loads the JSON file associated with the configured locale. If cachable is not false, and the localized messages have previously been loaded into memory, then they'll be reused.
localize(String key, {num count, LocalisonGender gender, List args, String fallback, bool quantify}) String
Returns a translated message matching the specified key. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toString() String
A string representation of this object. [...]


operator ==(Object other) bool
The equality operator. [...]

Static Properties

baseDirectory String
Returns the base directory where JSON files are loaded from, defaults to 'res/l10n'.
read / write
baseLocale Locale
Returns the base Locale of the app, defaults to English with no associated country.
read / write

Static Methods

of(BuildContext context) Localison
Returns the closest Localison instance to the passed context.
pluralLogic(num count, Locale locale, [int precision = 0]) LocalisonPlural
Implements the logic for plural selection.
quantitiesLogic(num count, Locale locale, Map<LocalisonQuantity, int> quantities) LocalisonPlural
Implements the quantities logic.


defaultLocale → const Locale
Localison's default Locale is English with no specific associated country.