API reference / @localizer/x-vue / LocalizerContext
Type Alias: LocalizerContext experimental
LocalizerContext =
object
Defined in: packages/x-vue/src/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
Property | Modifier | Type | Description |
---|---|---|---|
activeLocale | readonly | LocaleCode | The currently active locale code used for localization. |
Methods
localize()
Call Signature
localize<
T
>(localizable
):T
Defined in: packages/x-vue/src/lib/localizer-context.ts:37
Returns the localized value for the given input.
Type Parameters
Type Parameter | Description |
---|---|
T | Type of the localized value. |
Parameters
Parameter | Type | Description |
---|---|---|
localizable | Localizable <T > | The input to localize. |
Returns
T
Localized value of type T
.
Call Signature
localize<
A
,T
>(formatter
): (...args
) =>T
Defined in: packages/x-vue/src/lib/localizer-context.ts:51
Localizes a function that returns a localizable value.
Type Parameters
Type Parameter | Description |
---|---|
A extends unknown [] | The argument types for the function. |
T | The localized value type. |
Parameters
Parameter | Type | Description |
---|---|---|
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
Parameters
Parameter | Type |
---|---|
...args | A |
Returns
T
localizeArray()
localizeArray<
T
>(values
):Localized
<T
>
Defined in: packages/x-vue/src/lib/localizer-context.ts:64
Localizes an array of values using the given locale.
Type Parameters
Type Parameter | Description |
---|---|
T extends unknown [] | Type of the array elements. |
Parameters
Parameter | Type | Description |
---|---|---|
values | T | Array of values to localize. |
Returns
Localized
<T
>
Localized array.
localizeObject()
localizeObject<
T
>(values
):Localized
<T
>
Defined in: packages/x-vue/src/lib/localizer-context.ts:77
Localizes an object's properties by converting Localizable
values to their localized forms.
Type Parameters
Type Parameter | Description |
---|---|
T extends Record <string , unknown > | The input object type with properties that may be Localizable . |
Parameters
Parameter | Type | Description |
---|---|---|
values | T | The object with properties to localize. |
Returns
Localized
<T
>
A new object with Localizable
properties replaced by localized values.
setActiveLocale()
setActiveLocale(
locale
):void
Defined in: packages/x-vue/src/lib/localizer-context.ts:89
Sets the active locale for localization.
Parameters
Parameter | Type | Description |
---|---|---|
locale | LocaleCode | The locale code to set as active. |
Returns
void