Skip to main content

Class: MessageFormatDictionary

Defined in: packages/core/src/dictionary/MessageFormatDictionary.ts:16

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

Extends

Constructors

new MessageFormatDictionary()

new MessageFormatDictionary(): MessageFormatDictionary

Defined in: packages/core/src/dictionary/MessageFormatDictionary.ts:30

Initializes the dictionary.

Returns

MessageFormatDictionary

Example

dictionary.get('home.hello', {GENDER: 'UNSPECIFIED'});

Overrides

Dictionary.constructor

Properties

_dictionary

protected _dictionary: DictionaryData

Defined in: packages/core/src/dictionary/MessageFormatDictionary.ts:18


_language

protected _language: string

Defined in: packages/core/src/dictionary/MessageFormatDictionary.ts:17

Accessors

$dependencies

Get Signature

get static $dependencies(): never[]

Defined in: packages/core/src/dictionary/MessageFormatDictionary.ts:20

Returns

never[]

Methods

get()

get(key, parameters?): string

Defined in: packages/core/src/dictionary/MessageFormatDictionary.ts:89

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

Parameters

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?

ObjectParameters

The 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.

Overrides

Dictionary.get


getLanguage()

getLanguage(): string

Defined in: packages/core/src/dictionary/MessageFormatDictionary.ts:69

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.

Overrides

Dictionary.getLanguage


has()

has(key): boolean

Defined in: packages/core/src/dictionary/MessageFormatDictionary.ts:115

Tests whether the specified localization phrase exists in the dictionary.

Parameters

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.

Returns

boolean

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

Overrides

Dictionary.has


init()

init(config): void

Defined in: packages/core/src/dictionary/MessageFormatDictionary.ts:61

Initializes this dictionary with the provided language and localization phrases.

Parameters

config

DictionaryConfig

The dictionary configuration.

Returns

void

Overrides

Dictionary.init