Interface: Dictionary

Dictionary

The Dictionary is a manager and preprocessor of localization phrases for a single language. The format of the localization phrases depends on the implementation of this interface.

Methods


get(key [, parameters])

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

Parameters:
Name Type Argument Description
key string

The key identifying the localization phrase.

parameters Object.<string, (boolean|number|string|Date)> <optional>

The map of parameter names to the parameter values to use. Defaults to an empty plain object.

Returns:

The specified localization phrase with its placeholders evaluated using the provided parameters.

Type
string

getLanguage()

Returns the ISO 639-1 language code of the language this dictionary was initialized with.

Returns:

The language code representing the language of the localization phrases in this dictionary.

Type
string

has(key)

Tests whether the specified localization phrase exists in the dictionary.

Parameters:
Name Type Description
key string

The key identifying the localization phrase.

Returns:

true if the key exists and denotes a single localization phrase.

Type
boolean

init(config)

Initializes this dictionary with the provided language and localization phrases.

Parameters:
Name Type Description
config Object

The dictionary configuration. The language field is an ISO 639-1 language code specifying the language of the provided phrases. The dictionary field contains the localization phrases organized in an implementation-specific way.