DefaultLocale class
To set the default locale, use this class:
DefaultLocale.set("en-US");
DefaultLocale.set("es-ES");
DefaultLocale.set("pt-BR");
If you remove the default locale, it's considered English of the Unites States.
DefaultLocale.set(null); // Means "en-US".
DefaultLocale.set(""); // Means "en-US".
To get the locale as a lowercase string: DefaultLocale.locale;
When you translate strings using localize, localizeArgs, localizeFill, localizePlural, localizeVersion or localizeAllVersions, you can pass them the locale as a parameter. When you don't, the default locale defined here will be used. If you don't define a default locale, it will be "en-US".
The DefaultLocale class is visible only from the i18_exception_core package.
The i18_exception package lets you set the default locale in a different way:
By using the I18n widget class, which is turn is not visible from
the i18_exception_core package.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent 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
- locale → String
-
Returns the default locale, as a syntactically valid IETF BCP47 language tag
(which is compatible with the Unicode Locale Identifier (ULI) syntax).
Some examples of such identifiers: "en", "en-US", "es-419", "hi-Deva-IN" and
"zh-Hans-CN". See https://www.ietf.org/rfc/bcp/bcp47.html and
http://www.unicode.org/reports/tr35/ for details.
no setter
Static Methods
-
normalizeLocale(
String? localeStr) → String? - Normalizes a BCP47 language tag (which is compatible with the Unicode Locale Identifier (ULI) syntax), by adjusting the case of each component.
-
set(
String? locale) → void -
Use the given
localeto set the value of DefaultLocale.locale.