Skip to content

vue-i18n / general / ComposerNumberFormatting

Interface: ComposerNumberFormatting()<NumberFormats, Locales, DefinedNumberFormat, C, M, ResourceKeys>

Vue I18n Composition

Number formatting functions

Remarks

This is the interface for Composer

Type Parameters

Type ParameterDefault type
NumberFormats extends Record<string, any>object
Locales"en-US"
DefinedNumberFormat extends RemovedIndexResources<DefineNumberFormat>RemovedIndexResources<DefineNumberFormat>
CIsEmptyObject<DefinedNumberFormat> extends false ? PickupFormatPathKeys<{ [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K] }> : never
MIsEmptyObject<NumberFormats> extends false ? PickupFormatKeys<NumberFormats> : never
ResourceKeys extends C | MIsNever<C> extends false ? IsNever<M> extends false ? C | M : C : IsNever<M> extends false ? M : never

Call Signature

ts
ComposerNumberFormatting(value): string;

Number Formatting

Parameters

ParameterTypeDescription
valuenumberA number value

Returns

string

Formatted value

Remarks

If this is used in a reactive context, it will re-evaluate once the locale changes.

If UseI18nScope 'local' or Some UseI18nOptions are specified at useI18n, it’s translated in preferentially local scope datetime formats than global scope datetime formats.

If not, then it’s formatted with global scope number formats.

See about:

Call Signature

ts
ComposerNumberFormatting<Key, OptionsType>(value, keyOrOptions): IsPart<OptionsType> extends true ? NumberFormatPart[] : string;

Number Formatting

Type Parameters

Type ParameterDefault type
Key extends stringstring
OptionsType| ResourceKeys | Key | NumberOptions<ResourceKeys | Key, Locales>

Parameters

ParameterTypeDescription
valuenumberA number value
keyOrOptionsOptionsTypeA key of number formats, or additional options for number formatting

Returns

IsPart<OptionsType> extends true ? NumberFormatPart[] : string

Formatted value

Remarks

Overloaded n.

In this overloaded n, format in number format for a key registered in number formats.

Call Signature

ts
ComposerNumberFormatting<Key, OptionsType>(
   value, 
   keyOrOptions, 
   locale): IsPart<OptionsType> extends true ? NumberFormatPart[] : string;

Number Formatting

Type Parameters

Type ParameterDefault type
Key extends stringstring
OptionsType| ResourceKeys | Key | NumberOptions<ResourceKeys | Key, Locales>

Parameters

ParameterTypeDescription
valuenumberA number value
keyOrOptionsOptionsTypeA key of number formats, or additional options for number formatting
localeLocalesA locale, it will be used over than global scope or local scope.

Returns

IsPart<OptionsType> extends true ? NumberFormatPart[] : string

Formatted value

Remarks

Overloaded n.

In this overloaded n, format in number format for a key registered in number formats at target locale.

Released under the MIT License.