Localison class

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

Constructors

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

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
locale Locale
The Locale currently in use in this instance.
final
quantities Map<LocalisonQuantity, int>
Rules to represent a quantity that doesn't follow the plural rules of locale's language.
final
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.
final

Methods

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. [...]
inherited
toString() String
A string representation of this object. [...]
inherited

Operators

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

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.

Constants

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