Skip to main content

Introducing Workflow Engine, try for FREE workflowengine.io.

Class: FluentLocalizationEngine

Fluent.js implementation of ILocalizationEngine.

Implements​

Constructors​

Constructor​

new FluentLocalizationEngine(locale?): FluentLocalizationEngine

Constructor.

Parameters​

locale?​

`${string}-${string}`

the language full code, i.e. 'en-US'.

Returns​

FluentLocalizationEngine

Accessors​

language​

Get Signature​

get language(): `${string}-${string}`

The current language.

Returns​

`${string}-${string}`

Set Signature​

set language(locale): void

The current language.

Parameters​
locale​

`${string}-${string}`

Returns​

void

The current language.

Implementation of​

ILocalizationEngine.language

Methods​

addMessages()​

addMessages(locale, messages): LocalizationError[]

Adds messages to the localization engine.

Parameters​

locale​

`${string}-${string}`

the locale for the messages.

messages​

Record<string, unknown>

the messages to add.

Returns​

LocalizationError[]

the array of any localization errors that occurred.

Implementation of​

ILocalizationEngine.addMessages


getCompatibleId()​

getCompatibleId(rawId): string

Gets a compatible ID for localization engine.

Parameters​

rawId​

string

the raw ID to make compatible.

Returns​

string

the compatible ID.

Implementation of​

ILocalizationEngine.getCompatibleId


localizeErrorMessage()​

localizeErrorMessage(form, formData, language, componentStore, ruleKey): string | undefined

Localizes error messages for validation rules.

Parameters​

form​

IForm

the form containing localization data.

formData​

ComponentData

the form data for variable substitution.

language​

Language

the target language for localization.

componentStore​

ComponentStore

the component store to localize.

ruleKey​

string

the validation rule key.

Returns​

string | undefined

the localized error message or undefined.

Implementation of​

ILocalizationEngine.localizeErrorMessage


localizeProperties()​

localizeProperties(form, formData, language, componentStore, type?): Record<string, unknown>

Localizes properties for a component.

Parameters​

form​

IForm

the form containing localization data.

formData​

IFormData

the form data for variable substitution.

language​

Language

the target language for localization.

componentStore​

ComponentStore

the component store to localize.

type?​

string = 'component'

the type of localization (default: 'component').

Returns​

Record<string, unknown>

the object with localized property values.

Implementation of​

ILocalizationEngine.localizeProperties


testLocalization()​

testLocalization(localization, localizationStringId, language, formData): LocalizationError[] | string

Parameters​

localization​

string

the localization string to test.

localizationStringId​

string

the ID of the localization string.

language​

Language

the language for the test.

formData​

IFormData

the data to use for variable substitution.

Returns​

LocalizationError[] | string

the array of errors or the formatted result string.

Implementation of​

ILocalizationEngine.testLocalization