Skip to content

API reference / @localizer/x-vue / LocalizerContext

Type Alias: LocalizerContext
experimental
​

LocalizerContext = object

Defined in: lib/localizer-context.ts:25

Type representing a localizer context in Vue.js applications returned by useLocalizer() call. This type provides methods for localizing values, arrays, and objects, as well as a property for the active locale.

Properties ​

PropertyModifierTypeDescription
activeLocalereadonlyLocaleCodeThe currently active locale code used for localization.

Methods ​

localize() ​

Call Signature ​

localize<T>(localizable): T

Defined in: lib/localizer-context.ts:37

experimental

Returns the localized value for the given input.

Type Parameters ​
Type ParameterDescription
TType of the localized value.
Parameters ​
ParameterTypeDescription
localizableLocalizable<T>The input to localize.
Returns ​

T

Localized value of type T.

Call Signature ​

localize<A, T>(formatter): (...args) => T

Defined in: lib/localizer-context.ts:51

experimental

Localizes a function that returns a localizable value.

Type Parameters ​
Type ParameterDescription
A extends unknown[]The argument types for the function.
TThe localized value type.
Parameters ​
ParameterTypeDescription
formatter(...args) => Localizable<T>A function accepting arguments of type A and returning Localizable<T>.
Returns ​

A function accepting arguments of type A and returning T.

(...args) => T


localizeArray() ​

localizeArray<T>(values): Localized<T>

Defined in: lib/localizer-context.ts:64

experimental

Localizes an array of values using the given locale.

Type Parameters ​

Type ParameterDescription
T extends unknown[]Type of the array elements.

Parameters ​

ParameterTypeDescription
valuesTArray of values to localize.

Returns ​

Localized<T>

Localized array.


localizeObject() ​

localizeObject<T>(values): Localized<T>

Defined in: lib/localizer-context.ts:77

experimental

Localizes an object's properties by converting Localizable values to their localized forms.

Type Parameters ​

Type ParameterDescription
T extends Record<string, unknown>The input object type with properties that may be Localizable.

Parameters ​

ParameterTypeDescription
valuesTThe object with properties to localize.

Returns ​

Localized<T>

A new object with Localizable properties replaced by localized values.


setActiveLocale() ​

setActiveLocale(locale): void

Defined in: lib/localizer-context.ts:89

experimental

Sets the active locale for localization.

Parameters ​

ParameterTypeDescription
localeLocaleCodeThe locale code to set as active.

Returns ​

void