Skip to main content

Introducing Workflow Engine, try for FREE workflowengine.io.

Class: LocalizationStore

Observable storage of localization. Internal use only.

Implements​

Constructors​

Constructor​

new LocalizationStore(value?, engine): LocalizationStore

Creates a new LocalizationStore instance.

Parameters​

value?​

LocalizationValue = {}

the initial localization value.

engine​

ILocalizationEngine

the localization engine to use.

Returns​

LocalizationStore

Properties​

engine​

readonly engine: ILocalizationEngine

the localization engine to use.

Implementation of​

ILocalizationStore.engine


value​

readonly value: LocalizationValue = {}

the initial localization value.

Implementation of​

ILocalizationStore.value

Accessors​

langCodes​

Get Signature​

get langCodes(): `${string}-${string}`[]

Returns​

`${string}-${string}`[]

the available language codes.

Methods​

addLocalizationWithNewKey()​

addLocalizationWithNewKey(localization, oldComponentKey, newComponentKey): void

Inserts the localization values for a given component key. Replaces the old component key with the new component key.

Parameters​

localization​

LocalizationValue

the localization object for insertion.

oldComponentKey​

string

the old component key that needs to be replaced.

newComponentKey​

string

the new component key to be added.

Returns​

void


changeComponentKey()​

changeComponentKey(oldComponentKey, newComponentKey): void

Changes the component key for all languages in the value object.

Parameters​

oldComponentKey​

string

the old component key to be replaced.

newComponentKey​

string

the new component key to replace the old component key.

Returns​

void


findLocalizationKey()​

findLocalizationKey(languageFullCode): `${string}-${string}` | null

Finds the best matching localization key for the given language code. Looks for exact match first, then match by language code only.

Parameters​

languageFullCode​

`${string}-${string}`

the requested language full code.

Returns​

`${string}-${string}` | null

the best matching language full code or null if no match found.


getItems()​

getItems(languageFullCode): null | Record<string, unknown>

Returns all localization items provided by engine.

Parameters​

languageFullCode​

`${string}-${string}`

the full code (en-US, en-GB etc.).

Returns​

null | Record<string, unknown>

all localization items.

Implementation of​

ILocalizationStore.getItems


getLocalization()​

getLocalization(languageFullCode, componentKey, propertyName, type): unknown

Returns value of localization constant.

Parameters​

languageFullCode​

`${string}-${string}`

the full code (en-US, en-GB etc.) of the language we are looking to localize.

componentKey​

string

the component we are looking to localize.

propertyName​

string

the property name we are looking to localize.

type​

string

the type of localization.

Returns​

unknown

the value of localization constant.

Implementation of​

ILocalizationStore.getLocalization


getLocalizationForComponent()​

getLocalizationForComponent(componentKey): LocalizationValue

Retrieves the localization values for a given component key.

Parameters​

componentKey​

string

the key of the component to retrieve localization for.

Returns​

LocalizationValue

the object containing the localization values for the component in each supported language.


getLocalizationItemId()​

getLocalizationItemId(componentKey, propertyName): string

Returns normalized localization item id for the component property.

Parameters​

componentKey​

string

the component key.

propertyName​

string

the component property name.

Returns​

string

normalized localization item id.

Implementation of​

ILocalizationStore.getLocalizationItemId


hasLanguage()​

hasLanguage(languageFullCode): boolean

Checks that the specified language exists in the localization. Looks for exact match first, then match by language code only.

Parameters​

languageFullCode​

`${string}-${string}`

The full code (en-US, en-GB etc.) of the language to be checked.

Returns​

boolean

true if the specified language exists in the localization.

Implementation of​

ILocalizationStore.hasLanguage


hasLocalization()​

hasLocalization(componentKey, propertyName, type): boolean

Checks that the specified property has localization.

Parameters​

componentKey​

string

the component we are looking to localize.

propertyName​

string

the component's property name to be localized.

type​

string

the type of localization.

Returns​

boolean

true if the specified property has localization in at least one language.

Implementation of​

ILocalizationStore.hasLocalization


removeLocalization()​

removeLocalization(componentKey): void

Removes localization for component.

Parameters​

componentKey​

string

the component key that requires localization removal.

Returns​

void

Implementation of​

ILocalizationStore.removeLocalization


removeLocalizationForType()​

removeLocalizationForType(componentKey, type): void

Removes localization for component with specified type.

Parameters​

componentKey​

string

the component key that requires localization removal.

type​

string

the localization type.

Returns​

void

Implementation of​

ILocalizationStore.removeLocalizationForType


setLocalization()​

setLocalization(languageFullCode, componentKey, propertyName, type, value): void

Sets localization for component property.

Parameters​

languageFullCode​

`${string}-${string}`

the full code (en-US, en-GB etc.) of the language in which localization will be set.

componentKey​

string

the component key that requires localization.

propertyName​

string

the component's property name to be localized.

type​

string

the type of localization.

value​

unknown

the localization value to persist.

Returns​

void

Implementation of​

ILocalizationStore.setLocalization