Class: Localization

H.ui.i18n.Localization

new H.ui.i18n.Localization (locale, opt_translationMap)

This class is used for internationalization of UI components.

Name Type Description
locale string

A locale code, for example 'en-GB'

opt_translationMap Object optional

An optional translation map for this locale. If not provided, the Locale is initialized with default translations, if available

Methods

getKeys ()Array.<string>

This method retrieves translation keys for current locale. Keys from this set can be used to get translations via translate method.

Returns:
Type Description
Array.<string> A string containin translation keys

getLocale ()string

This method retrieves the current locale code, for example 'en-US'.

Returns:
Type Description
string A locale identifier

hasKey (key)boolean

This method retrieves a Boolean value indicating whether the given localization object has a translation for the specified translation key.

Name Type Description
key string

A transaltion key

Returns:
Type Description
boolean true if the key exists, otherwise false.

translate (key)string

This method retrieves translation for the key provided by the caller. It throws an exception if a translation is not available.

Name Type Description
key string

A translation key

Returns:
Type Description
string A localized string corresponding to the provided key