Skip to main content

Class: Dictionary

@ima/core.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.

Hierarchy

Constructors

constructor

new Dictionary()

Methods

get

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.

Parameters

NameTypeDescription
keyneverThe key identifying the localization phrase.
parameters?ObjectParametersThe map of parameter names to the parameter values to use. Defaults to an empty plain object.

Returns

string

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

Defined in

packages/core/src/dictionary/Dictionary.ts:60


getLanguage

getLanguage(): string

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

Returns

string

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

Defined in

packages/core/src/dictionary/Dictionary.ts:44


has

has(key): boolean

Tests whether the specified localization phrase exists in the dictionary.

Parameters

NameTypeDescription
keystringThe key identifying the localization phrase. @returntrue if the key exists and denotes a single localization phrase, otherwise false.

Returns

boolean

Defined in

packages/core/src/dictionary/Dictionary.ts:72


init

init(config): void

Initializes this dictionary with the provided language and localization phrases.

Parameters

NameTypeDescription
configDictionaryConfigThe dictionary configuration.

Returns

void

Defined in

packages/core/src/dictionary/Dictionary.ts:33