LocaleManager

Configs

1

Specifies if Localizable.L() function should throw error if no localization is found at runtime.

Properties

3

Get/set currently used locale. Setter calls applyLocale.

locales: Localesreadonly

Get/set currently registered locales. Alias for LocaleHelper.locales.

Specifies if Localizable.L() function should throw error if no localization is found at runtime.

Functions

1

Applies a locale by string name or publishes new locale configuration with publishLocale and applies it. If locale is specified by string name, like 'En', it must be published before applying it.

ParameterTypeDescription
nameOrConfigString | Locale

String name of locale (for example En or SvSE) or locale object

configLocale | Boolean

Locale object. Pass true to reapply locale which is passed as first method parameter.

Returns: Locale | Promise -

locale object or Promise which resolves with locale object after it was loaded

Events

1

Fires when a locale is applied

// Adding a listener using the "on" method
localeManager.on('locale', ({ source, locale, locale.oldLocaleName, locale.oldLocaleCode }) => {

});
ParameterTypeDescription
sourceLocaleManager

The Locale manager instance.

localeLocale

Locale configuration

locale.oldLocaleNameString

The name (eg, `'En") of the previous locale which was replaced.

locale.oldLocaleCodeString

The code (eg, `'en-US") of the previous locale which was replaced.

Event handlers

1

Called when a locale is applied

new LocaleManager({
    onLocale({ source, locale }) {

    }
});
ParameterTypeDescription
sourceLocaleManager

The Locale manager instance.

localeLocale

Locale configuration

locale.oldLocaleNameString

The name (eg, `'En") of the previous locale which was replaced.

locale.oldLocaleCodeString

The code (eg, `'en-US") of the previous locale which was replaced.