Localizer class final
Translated text for a form: the itext engine.
Port of org.javarosa.core.services.locale.Localizer. A text id may
carry a form after a semicolon (id;short, id;image, id;audio,
id;video, id;big-image, id;guidance). Lookups can fall back to the
form-less id (fallbackDefaultForm) and to the default locale
(fallbackDefaultLocale); see getTextForLocale.
Constructors
Properties
-
availableLocales
→ List<
String> -
The defined locales, in the order they were added.
no setter
- defaultLocale ↔ String?
-
The default locale, or
null.getter/setter pair - fallbackDefaultForm → bool
-
Whether lookups of
id;formfall back toid.final - fallbackDefaultLocale → bool
-
Whether lookups fall back to the default locale.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- locale ↔ String?
-
The current locale, or
nullif none is set.getter/setter pair - nextLocale → String?
-
The locale after the current one (cycling), the default locale if
none is current, or
null.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addAvailableLocale(
String locale) → bool -
Defines
locale(with no mappings); returnsfalseif it already exists. -
destroyLocale(
String locale) → bool -
Removes
localeand its data; clears the default locale if it waslocale. Returns whether it existed. -
getLocaleData(
String? locale) → Map< String, String> ? -
All mappings of
locale(with the default locale's underneath when fallbackDefaultLocale is on), ornulliflocaleisn't defined. -
getLocaleMap(
String? locale) → Map< String, String> - Like getLocaleData, but throws UnregisteredLocaleException for an undefined locale.
-
getLocalizedText(
String textId) → String -
Like getText, but throws
NoLocalizedTextExceptionif there is no text. -
getRawText(
String? locale, String textId) → String? -
The text for exactly
textIdinlocale, without fallbacks. -
getText(
String textId) → String? -
The text for
textIdin the current locale with fallbacks, ornull. -
getTextForLocale(
String textId, String? locale) → String? -
The text for
textIdinlocale, searching in order: -
getTextWithArgs(
String textId, List< String> args) → String -
The text for
textIdin the current locale with${0},${1}… replaced byargs. ThrowsNoLocalizedTextExceptionif missing. -
getTextWithNamedArgs(
String textId, Map< String, String> args) → String -
The text for
textIdin the current locale with${name}replaced fromargs. ThrowsNoLocalizedTextExceptionif missing. -
hasLocale(
String? locale) → bool -
Whether
localeis defined (falsefornull). -
hasMapping(
String? locale, String? textId) → bool -
Whether
locale's own sources maptextId(no fallbacks). Throws UnregisteredLocaleException iflocaleisn't defined. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerLocaleResource(
String locale, LocaleDataSource resource) → void -
Adds
resourceas a source of text forlocale(which need not have been defined with addAvailableLocale). -
registerLocalizable(
Localizable localizable) → void -
Registers
localizable(once); it is told the current locale at once if one is set. -
setToDefault(
) → void - Makes the default locale current. Throws StateError if there is no default locale.
-
toString(
) → String -
A string representation of this object.
inherited
-
unregisterAll(
) → void - Unregisters all Localizables.
-
unregisterLocalizable(
Localizable localizable) → void -
Unregisters
localizable.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
clearArguments(
String text) → String -
textwith every${...}placeholder removed. -
getArgs(
String text) → List< String> -
The distinct
${...}argument names intext, in order. -
processArguments(
String text, List< String> args, [int currentArg = 0]) → String -
Replaces
${...}placeholders intextwithargs:${n}takesargs[n]when n is a valid index, any other placeholder takes the next unused argument. Substituted text is not processed again. -
processNamedArguments(
String text, Map< String, String> args) → String -
Replaces
${name}intextwith values fromargs; unknown names are left as is. Substituted text is not processed again.