Documentation

localize( languageTag, i18nValue )

Localize the given internationalized object using the given languageTag.

Parameters

  • languageTag {String}: The languageTag to lookup a localization with Maybe undefined if the value is not i18n (app does not use i18n)

  • i18nValue {*}: A possibly internationalized value:

  • When passing a primitive value, it is returned as-is.
  • When passing an object, the languageTag is used as a key within that object.

Returns

  • {*}: The localized value if found, undefined otherwise

localizeRelaxed( languageTag, i18nValue )

For controls (such as a date-picker), we cannot anticipate all required language tags, as they may be app-specific. The relaxed localize behaves like localize if an exact localization is available. If not, the language tag is successively generalized by stripping off the rightmost sub-tags until a localization is found. Eventually, a fallback ('en') is used.

Parameters

  • languageTag {String}: The languageTag to lookup a localization with. Maybe undefined if the value is not i18n (app does not use i18n)

  • i18nValue {*}: A possibly internationalized value:

  • When passing a primitive value, it is returned as-is.
  • When passing an object, the languageTag is used as a key within that object.

Returns

  • {*}: The localized value if found, undefined otherwise

localizer( languageTag )

Encapsulate a given languageTag in a partially applied localize function.

Parameters

  • languageTag {String}: The languageTag to lookup localizations with

Returns

  • {Function<|>}: A single-arg localize-Function, which always uses the given language-tag It also has a .format-method, which can be used as a shortcut to text.format( localize( x ), args )

function Object() { [native code] }#format()

Shortcut to text.format, for simple chaining to the localizer.

These are equal:

  • text.format( i18n.localizer( tag )( i18nValue ), arg1, arg2 )
  • i18n.localizer( tag ).format( i18nValue, arg1, arg2 ).

languageTagFromI18n( String, )

Retrieve the language tag of the current locale from an i18n model object, such as used on the scope.

Parameters

  • String, {locale:}: An internationalization model, with reference to the currently active locale and a map from locales to language tags.

Returns

  • {String}: The localized value if found, undefined otherwise