Skip to main content

Introducing Workflow Engine, try for FREE workflowengine.io.

Class: LocalizationStore

@react-form-builder/core.LocalizationStore

Observable storage of localization. Internal use only.

Constructors

constructor

new LocalizationStore(value?)

The constructor.

Parameters

NameTypeDescription
valueLocalizationValuethe initial localization value.

Properties

value

Readonly value: LocalizationValue = {}

The localization data.

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

NameTypeDescription
localizationLocalizationValuethe localization object for insertion.
oldComponentKeystringthe old component key that needs to be replaced.
newComponentKeystringthe 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

NameTypeDescription
oldComponentKeystringthe old component key to be replaced.
newComponentKeystringthe new component key to replace the old component key.

Returns

void


getFluentBundle

getFluentBundle(languageFullCode): FluentBundle

If the FluentBundle for the specified language is found, this function returns it. Otherwise, an empty FluentBundle is returned.

Parameters

NameTypeDescription
languageFullCodestringthe full code (en-US, en-GB etc.) of the language to get fluent bundle.

Returns

FluentBundle

the FluentBundle for the specified language.


getLocalization

getLocalization(languageFullCode, componentKey, propertyName, type): undefined | string

Returns value of localization constant.

Parameters

NameTypeDescription
languageFullCodestringthe full code (en-US, en-GB etc.) of the language we are looking to localize.
componentKeystringthe component we are looking to localize.
propertyNamestringthe property name we are looking to localize.
typestringthe type of localization.

Returns

undefined | string

the value of localization constant.


getLocalizationForComponent

getLocalizationForComponent(componentKey): LocalizationValue

Retrieves the localization values for a given component key.

Parameters

NameTypeDescription
componentKeystringthe key of the component to retrieve localization for.

Returns

LocalizationValue

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


hasLanguage

hasLanguage(languageFullCode): boolean

Checks that the specified language exists in the localization.

Parameters

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

Returns

boolean

true if the specified language exists in the localization.


hasLocalization

hasLocalization(componentKey, propertyName, type): boolean

Checks that the specified property has localization.

Parameters

NameTypeDescription
componentKeystringthe component we are looking to localize.
propertyNamestringthe component's property name to be localized.
typestringthe type of localization.

Returns

boolean

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


removeLocalization

removeLocalization(componentKey): void

Removes localization for component.

Parameters

NameTypeDescription
componentKeystringthe component key that requires localization removal.

Returns

void


removeLocalizationForType

removeLocalizationForType(componentKey, type): void

Removes localization for component with specified type.

Parameters

NameTypeDescription
componentKeystringthe component key that requires localization removal.
typestringthe localization type.

Returns

void


setLocalization

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

Sets localization for component property.

Parameters

NameTypeDescription
languageFullCodestringthe full code (en-US, en-GB etc.) of the language in which localization will be set.
componentKeystringthe component key that requires localization.
propertyNamestringthe component's property name to be localized.
typestringthe type of localization.
valuestringthe localization value.

Returns

void