MessageFormatDictionary ⇐ Dictionary 

Implementation of the Dictionary interface that relies on compiled MessageFormat localization messages for its dictionary.

Kind: global class
Extends: Dictionary


new MessageFormatDictionary() 

Initializes the dictionary.


messageFormatDictionary._language : string 

The language of the phrases in the dictionary, represented as a ISO 639-1 language code.

Kind: instance property of MessageFormatDictionary


messageFormatDictionary._dictionary : Object.<string, Object.<string, function(Object.<string, (number\|string)>): string>> 

Stored dictionary.

Kind: instance property of MessageFormatDictionary


messageFormatDictionary.init(config) 

Initializes this dictionary with the provided language and localization phrases.

Kind: instance method of MessageFormatDictionary

Param Type Description
config Object.<string, \*> The dictionary configuration.
config.language string The language property is an ISO 639-1 language code specifying the language of the provided phrases.
config.dictionary Object.<string, Object.<string, function(Object.<string, (number\|string)>): string>> The dictionary field contains the localization phrases organized in a deep plain object map. The top-level key is the name of the phrase group, the bottom-level key is the phrase key. The bottom-level value is the localization phrase generator that takes the phrase placeholder values map as an argument and produces the localization phrase with its placeholders evaluated using the provided placeholder values.

messageFormatDictionary.getLanguage() 

Kind: instance method of MessageFormatDictionary


messageFormatDictionary.get(key, [parameters]) ⇒ string 

Retrieves the localization phrase identified by the specified key, evaluates the phrase’s placeholder expressions using the provided parameters and returns the result.

Kind: instance method of MessageFormatDictionary
Returns: string - The specified localization phrase with its placeholders evaluated using the provided parameters.

Param Type Description
key string The key identifying the localization phrase. The key consists of at least two parts separated by dots. The first part denotes the name of the source JSON localization file, while the rest denote a field path within the localization object within the given localization file.
[parameters] Object.<string, (boolean\|number\|string\|Date)> The map of parameter names to the parameter values to use. Defaults to an empty plain object.

messageFormatDictionary.has(key) ⇒ boolean 

Tests whether the specified localization phrase exists in the dictionary.

Kind: instance method of MessageFormatDictionary
Returns: boolean - true if the key exists and denotes a single localization phrase, otherwise false.

Param Type Description
key string The key identifying the localization phrase. The key consists of at least two parts separated by dots. The first part denotes the name of the source JSON localization file, while the rest denote a field path within the localization object within the given localization file.