Last date modified: 2026-Apr-23
i18n
Helper methods to support internationalization of message text. These functions are available under the `convenienceApi.i18n` namespace.
Methods
- tr(key) ⇒
String - Looks up a key and returns the localized string for the current locale.
- getLocale() ⇒
String - Returns a string for the current browser's language code.
- nf(options, lang) ⇒
Intl.NumberFormat - Returns an Intl.NumberFormat object for the given locale, with the specified options applied.
- df(options, lang) ⇒
Intl.DateTimeFormat - Returns an Intl.DateTimeFormat object for the given locale, with the specified options applied.
- addResources(lang, resources) ⇒
undefined - Adds custom translations. When this method is used with the tr() method, it eliminates the need for manual locale resolution.
Properties Details
tr(key) ⇒ String
Looks up a key and returns the localized string for the current locale.
Returns: String - A localized string based on the current locale.
| Param | Type | Description |
|---|---|---|
| key | String
|
Indicates the localized string to return. |
getLocale() ⇒ String
Returns a string for the current browser's language code.
Returns: String - A string representing the browser's current locale.
nf(options, lang) ⇒ Intl.NumberFormat
Returns an Intl.NumberFormat object for the given locale, with the specified options applied.
Returns: Intl.NumberFormat - A number format object for the given locale and specified options applied.
| Param | Type | Description |
|---|---|---|
| options | Object | null |
The "options" passed to a NumberFormat constructor, as described in MDN, or null. |
| lang | String
|
Indicates a country, origin, or language setting. |
df(options, lang) ⇒ Intl.DateTimeFormat
Returns an Intl.DateTimeFormat object for the given locale, with the specified options applied.
Returns: Intl.DateTimeFormat - A date/time format object for the given locale and specified options applied.
| Param | Type | Description |
|---|---|---|
| options | Object | null |
The "options" passed to a DateTimeFormat constructor, as described in MDN, or null. |
| lang | String
|
Indicates a country, origin, or language setting. |
addResources(lang, resources) ⇒ undefined
Adds custom translations. When this method is used with the tr() method, it eliminates the need for manual locale resolution.
| Param | Type | Description |
|---|---|---|
| lang | String
|
Indicates a country, origin, or language setting. |
| resources | Object
|
Object which is a key-value pair dictionary, where the key is the localization key, and value is the localized string corresponding to the key, for the given locale. |