Maps API for JavaScript Developer's Guide

H.ui.i18n.Localization

Class Summary

This class is used for internationalization of UI components.

[ For full details, see the Class Details ]

Method Summary

Table 1. Methods
Methods

getLocale () : {string}

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

getKeys () : {Array<string>}

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

hasKey (key) : {boolean}

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

translate (key) : {string}

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

Class Description

This class is used for internationalization of UI components.

Constructor Details

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

Parameters:
 
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

Method Details

getLocale () : {string}

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

Returns:
 
{string}
A locale identifier

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:
 
{Array<string>}
A string containin translation keys

hasKey (key) : {boolean}

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

Parameters:
 
key:
{string}
 
A transaltion key
Returns:
 
{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.

Parameters:
 
key:
{string}
 
A translation key
Returns:
 
{string}
A localized string corresponding to the provided key