LocaleHelper
Thin class which provides locale management methods. Class doesn't import other API classes and can be used separately for publishing locales before importing product classes.
Locale should be published with publishLocale method before it is available for localizing of Bryntum API classes and widgets.
Example:
LocaleHelper.publishLocale({
localeName : 'En',
localeDesc : 'English (US)',
localeCode : 'en-US',
... (localization key:value pairs)
});
or for asynchronous loading from remote path on applying locale
LocaleHelper.publishLocale({
localeName : 'En',
localeDesc : 'English (US)',
localeCode : 'en-US',
localePath : 'https://my-server/localization/en.js'
});
Properties
3
Properties
3Get current locale config specified by localeName.
If no current locale specified, returns default En locale or first published locale
or empty locale object if no published locales found.
Get/set current locale name. Defaults to "En"
Functions
3
Functions
3Merges all properties of provided locale objects into new locale object. Locales are merged in order they provided and locales which go later replace same properties of previous locales.
| Parameter | Type | Description |
|---|---|---|
locales | Object | Locales to merge |
Merged locale
Publishes a locale to make it available for applying. Published locales are available in locales.
Recommended usage:
LocaleHelper.publishLocale({
localeName : 'En',
localeDesc : 'English (US)',
localeCode : 'en-US',
... (localization key:value pairs)
});
for backward compatibility (prior to 5.3.0 version):
LocaleHelper.publishLocale('En', {
name : 'En',
desc : 'English (US)',
code : 'en-US',
locale : {
... (localization key:value pairs)
}
});
Publishing a locale will automatically merge it's localization keys with existing locale matching by locale name,
replacing existing one with new. To replace existing locale entirely pass true to optional config parameter.
Example:
LocaleHelper.publishLocale({
localeName : 'En',
localeDesc : 'English (US)',
localeCode : 'en-US',
... (localization key:value pairs)
}, true);
| Parameter | Type | Description |
|---|---|---|
nameOrConfig | String | Locale | String name of locale (for example |
config | Locale | Boolean | Locale object.
Not used if locale object is passed as first method parameter.
Path |
Locale object
Removes all properties from locale that are present in the provided toTrim.
| Parameter | Type | Description |
|---|---|---|
locale | Object | Locale to process |
toTrim | Object | Object enumerating properties that should be removed.
When |
Typedefs
3
Typedefs
3Locale configuration object which contains locale properties alongside with localization pairs.
Example:
{
localeName : 'En',
localeDesc : 'English (US)',
localeCode : 'en-US',
... (localization key:value pairs)
}
| Parameter | Type | Description |
|---|---|---|
localeName | String | Locale name. For example: "En" |
localeDesc | String | Locale description to be shown in locale picker list. For example: "English (US)" |
localeCode | String | Locale code. Two letter locale code or two letter locale and two letter country code.
For example: |
localePath | String | Locale path for asynchronous loading using AjaxHelper get request |
Object which contains key: value localization pairs.
Key value may have String, Function, LocaleKeys or Object type.
Example:
{
title : 'Title',
count : number => `Count is ${number}`,
MyClass : {
foo : 'bar'
}
}
| Parameter | Type | Description |
|---|---|---|
key | String | function | LocaleKeys | Object | localization key |