Skip to main content

Introducing Workflow Engine, try for FREE workflowengine.io.

Interface: ILocalizationEngine

The form localization engine.

Properties

language

language: `${string}-${string}`

The current language.


testLocalization()?

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

Tests localization by formatting a message with given data.

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

string | LocalizationError[]

the array of errors or the formatted result string.

Methods

addMessages()

addMessages(locale, messages): LocalizationError[]

Adds messages to the localization engine.

Parameters

locale

string

the locale for the messages.

messages

Record<string, string>

the messages to add.

Returns

LocalizationError[]

the array of any localization errors that occurred.


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.


localizeErrorMessage()

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

Localizes error messages for validation rules.

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.

ruleKey

string

the validation rule key.

Returns

undefined | string

the localized error message or undefined.


localizeProperties()

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

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

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

Returns

Record<string, any>

the object with localized property values.