Skip to content

API Reference

This page is generated from English JSDoc comments by TypeDoc.

Related guides:

index

Interfaces

LocaleDictionary

Defined in: types.ts:6

Indexable

[key: string]: LocaleValue


LocaleLocalizerDictionary

Defined in: runtime.ts:56

Nested localizer dictionary returned by $l and localizer helpers.

Indexable

[key: string]: LocaleLocalizerDictionary | LocaleTemplateFunction | ((values?, plural?) => string)

Type Aliases

InternationalizationInstance

InternationalizationInstance = object

Defined in: runtime.ts:110

Installed runtime instance shared through Vue provide/inject.

Properties

locale

locale: string

Defined in: runtime.ts:112

Currently loaded locale code.

primaryLocale

primaryLocale: string

Defined in: runtime.ts:114

Primary locale code.

ready

ready: Promise<void>

Defined in: runtime.ts:116

Promise that settles after the initial locale load attempt.

Methods

install()

install(app): void

Defined in: runtime.ts:120

Installs the instance into a Vue app.

Parameters
app

App

Returns

void

loadLocale()

loadLocale(locale): Promise<void>

Defined in: runtime.ts:118

Loads a locale bundle if it has not already been loaded.

Parameters
locale

string

Returns

Promise<void>


InternationalizationRuntimeOptions

InternationalizationRuntimeOptions = object

Defined in: runtime.ts:92

Runtime options used to create an internationalization instance.

Properties

dateTimeFormats?

optional dateTimeFormats?: LocaleDateTimeFormatSource

Defined in: runtime.ts:104

Date-time format presets keyed by locale and preset name.

fallbackLocale?

optional fallbackLocale?: string

Defined in: runtime.ts:98

Locale used when a message is missing from the active locale.

initialLocale?

optional initialLocale?: string

Defined in: runtime.ts:96

Locale to load first. Defaults to primaryLocale.

loaders

loaders: Partial<Record<string, LocaleLoader>>

Defined in: runtime.ts:102

Locale bundle loaders keyed by locale code.

messageSyntax?

optional messageSyntax?: LocaleMessageSyntax

Defined in: runtime.ts:100

Message parser used for string messages.

numberFormats?

optional numberFormats?: LocaleNumberFormatSource

Defined in: runtime.ts:106

Number format presets keyed by locale and preset name.

primaryLocale

primaryLocale: string

Defined in: runtime.ts:94

Locale used as the primary fallback and generated type source.


InternationalizationScopeName

InternationalizationScopeName = keyof LocaleScope

Defined in: runtime.ts:30

Names of the locale scopes available at runtime.


LocaleBundle

LocaleBundle = object

Defined in: runtime.ts:83

Locale payload loaded for one locale.

Properties

global?

optional global?: RuntimeLocaleDictionary

Defined in: runtime.ts:84

modules?

optional modules?: Partial<Record<string, RuntimeLocaleDictionary>>

Defined in: runtime.ts:85


LocaleDateTimeFormatName

LocaleDateTimeFormatName = string

Defined in: runtime.ts:41


LocaleDateTimeFormatOptions

LocaleDateTimeFormatOptions = Intl.DateTimeFormatOptions

Defined in: runtime.ts:35


LocaleDateTimeFormatSource

LocaleDateTimeFormatSource = Partial<Record<string, Record<string, LocaleDateTimeFormatOptions>>>

Defined in: runtime.ts:38

Date-time format presets keyed by locale and preset name.


LocaleDateTimeFormatter

LocaleDateTimeFormatter = (value, format?, options?) => string

Defined in: runtime.ts:44

Formats a date-time value with either a preset name or inline Intl options.

Parameters

value

LocaleDateTimeValue

format?

LocaleDateTimeFormatName | LocaleDateTimeFormatOptions

options?

LocaleDateTimeFormatOptions

Returns

string


LocaleDateTimeValue

LocaleDateTimeValue = Date | number | string

Defined in: runtime.ts:32

Values accepted by date-time formatters.


LocaleLoader

LocaleLoader = () => Promise<LocaleBundle | { default: LocaleBundle; }>

Defined in: runtime.ts:89

Async loader for a locale payload.

Returns

Promise<LocaleBundle | { default: LocaleBundle; }>


LocaleLocalizerScope

LocaleLocalizerScope<TGlobal, TModule> = object

Defined in: runtime.ts:68

Localizer functions grouped by global and SFC scopes.

Type Parameters

TGlobal

TGlobal extends RuntimeLocaleDictionary = RuntimeLocaleDictionary

TModule

TModule extends RuntimeLocaleDictionary = RuntimeLocaleDictionary

Properties

env

env: TypedLocaleLocalizerDictionary<TGlobal>

Defined in: runtime.ts:72

sfc

sfc: TypedLocaleLocalizerDictionary<TModule>

Defined in: runtime.ts:73


LocaleMessageAst

LocaleMessageAst = object

Defined in: message.ts:25

Parsed lightweight Vue-style message.

Properties

cases

cases: LocaleMessageToken[][]

Defined in: message.ts:26


LocaleMessageContext

LocaleMessageContext = object

Defined in: message.ts:30

Context used when formatting a locale message.

Properties

locale?

optional locale?: string

Defined in: message.ts:31

plural?

optional plural?: number

Defined in: message.ts:34

resolveLinked?

optional resolveLinked?: (key) => string

Defined in: message.ts:35

Parameters
key

string

Returns

string

syntax?

optional syntax?: LocaleMessageSyntax

Defined in: message.ts:32

values?

optional values?: LocaleMessageValues

Defined in: message.ts:33


LocaleMessageFunction

LocaleMessageFunction<TValues> = object["bivarianceHack"]

Defined in: runtime.ts:26

User-provided message function signature for programmatic dictionaries.

Type Parameters

TValues

TValues = unknown


LocaleMessageListValues

LocaleMessageListValues = LocaleMessageValue[]

Defined in: message.ts:10

Positional values passed to Vue-style list interpolation.


LocaleMessageNamedValues

LocaleMessageNamedValues = Record<string, LocaleMessageValue>

Defined in: message.ts:8

Named values passed to locale message formatters.


LocaleMessages

LocaleMessages = Partial<Record<string, LocaleDictionary>>

Defined in: plugin.ts:45

Locale dictionaries keyed by locale code.


LocaleMessageSyntax

LocaleMessageSyntax = "vue" | "icu"

Defined in: message.ts:14

Supported locale message syntaxes.


LocaleMessageToken

LocaleMessageToken = { type: "text"; value: string; } | { key: string; type: "named"; } | { index: number; type: "list"; } | { type: "literal"; value: string; } | { key: string; modifier?: string; type: "linked"; }

Defined in: message.ts:17

Token produced by the lightweight Vue-style message parser.


LocaleMessageValue

LocaleMessageValue = string | number | bigint | boolean | null | undefined | Date

Defined in: message.ts:6

Primitive value accepted by locale message formatters.


LocaleMessageValues

LocaleMessageValues = LocaleMessageNamedValues | LocaleMessageListValues

Defined in: message.ts:12

Values passed to locale message formatters.


LocaleNumberFormatName

LocaleNumberFormatName = string

Defined in: runtime.ts:42


LocaleNumberFormatOptions

LocaleNumberFormatOptions = Intl.NumberFormatOptions

Defined in: runtime.ts:36


LocaleNumberFormatSource

LocaleNumberFormatSource = Partial<Record<string, Record<string, LocaleNumberFormatOptions>>>

Defined in: runtime.ts:40

Number format presets keyed by locale and preset name.


LocaleNumberFormatter

LocaleNumberFormatter = (value, format?, options?) => string

Defined in: runtime.ts:50

Formats a number value with either a preset name or inline Intl options.

Parameters

value

LocaleNumberValue

format?

LocaleNumberFormatName | LocaleNumberFormatOptions

options?

LocaleNumberFormatOptions

Returns

string


LocaleNumberValue

LocaleNumberValue = number | bigint

Defined in: runtime.ts:34

Values accepted by number formatters.


LocaleTemplateFunction

LocaleTemplateFunction = (values?, plural?) => string

Defined in: runtime.ts:24

Function signature used by generated localizers.

Parameters

values?

LocaleTemplateValues | LocaleTemplateValue[] | number

plural?

number

Returns

string


LocaleTemplateValue

LocaleTemplateValue = string | number | bigint | boolean | null | undefined | Date

Defined in: runtime.ts:20

Primitive value accepted by the lightweight template formatter.


LocaleTemplateValues

LocaleTemplateValues = Record<string, LocaleTemplateValue>

Defined in: runtime.ts:22

Named values accepted by the lightweight template formatter.


RuntimeLocaleDictionary

RuntimeLocaleDictionary = Record<string, any>

Defined in: runtime.ts:8

Runtime dictionary shape used when generated types intentionally skip detailed keys.


SfcTransformMode

SfcTransformMode = "locale-sources" | "all"

Defined in: plugin.ts:48

Controls which Vue SFC files receive $locale and $l bindings.


TypedLocaleLocalizerDictionary

TypedLocaleLocalizerDictionary<TDictionary> = { [TKey in keyof TDictionary]: TDictionary[TKey] extends LocaleMessageFunction ? TDictionary[TKey] : TDictionary[TKey] extends RuntimeLocaleDictionary ? TypedLocaleLocalizerDictionary<TDictionary[TKey]> : LocaleTemplateFunction }

Defined in: runtime.ts:60

Localizer dictionary derived from a locale dictionary type.

Type Parameters

TDictionary

TDictionary extends RuntimeLocaleDictionary


VueInternationalizationOptions

VueInternationalizationOptions = object

Defined in: plugin.ts:51

Options for the Vite plugin and the matching Volar plugin configuration.

Properties

buildStrategy?

optional buildStrategy?: "virtual" | "inline-chunks"

Defined in: plugin.ts:57

Controls whether locale payloads are loaded as virtual chunks or inlined into locale-specific chunks.

global?

optional global?: LocaleEnvSources

Defined in: plugin.ts:55

Global dictionaries keyed by locale code.

messageSyntax?

optional messageSyntax?: LocaleMessageSyntax

Defined in: plugin.ts:61

Message parser used for string messages in the whole project.

primaryLocale

primaryLocale: string

Defined in: plugin.ts:53

Locale used as the source of generated TypeScript types.

scan?

optional scan?: ScanVueFilesOptions

Defined in: plugin.ts:59

Glob filters used when collecting Vue files at startup.

sfcTransform?

optional sfcTransform?: SfcTransformMode

Defined in: plugin.ts:63

Controls which Vue SFC files receive injected $locale and $l bindings.

Variables

Internationalization

const Internationalization: DefineComponent<ExtractPropTypes<{ locale: { default: undefined; type: PropType<LocaleScope<RuntimeLocaleDictionary, RuntimeLocaleDictionary>>; }; message: { default: undefined; type: StringConstructor; }; path: { default: undefined; type: StringConstructor; }; plural: { default: undefined; type: NumberConstructor; }; scope: { default: string; type: PropType<keyof LocaleScope<RuntimeLocaleDictionary, RuntimeLocaleDictionary>>; }; values: { default: undefined; type: PropType<number | LocaleMessageValues>; }; }>, () => VNode<RendererNode, RendererElement, {[key: string]: any; }>, { }, { }, { }, ComponentOptionsMixin, ComponentOptionsMixin, { }, string, PublicProps, ToResolvedProps<ExtractPropTypes<{ locale: { default: undefined; type: PropType<LocaleScope<RuntimeLocaleDictionary, RuntimeLocaleDictionary>>; }; message: { default: undefined; type: StringConstructor; }; path: { default: undefined; type: StringConstructor; }; plural: { default: undefined; type: NumberConstructor; }; scope: { default: string; type: PropType<keyof LocaleScope<RuntimeLocaleDictionary, RuntimeLocaleDictionary>>; }; values: { default: undefined; type: PropType<number | LocaleMessageValues>; }; }>, { }>, { locale: LocaleScope<RuntimeLocaleDictionary, RuntimeLocaleDictionary>; message: string; path: string; plural: number; scope: keyof LocaleScope<RuntimeLocaleDictionary, RuntimeLocaleDictionary>; values: number | LocaleMessageValues; }, { }, { }, { }, string, ComponentProvideOptions, true, { }, any>

Defined in: runtime.ts:146

Vue component for component interpolation.

It renders a message from either the message prop or a locale scope and path, replacing named placeholders with matching slots when present.

Functions

compileLocaleMessage()

compileLocaleMessage(message): LocaleMessageAst

Defined in: message.ts:50

Parses a lightweight Vue-style locale message into tokens.

Parameters

message

string

Returns

LocaleMessageAst


createComponentLocale()

createComponentLocale<TModule>(moduleUrl): TModule

Defined in: runtime.ts:304

Creates a lazy SFC dictionary proxy for component static $locale access.

This is primarily used by generated component options.

Type Parameters

TModule

TModule extends RuntimeLocaleDictionary = RuntimeLocaleDictionary

Parameters

moduleUrl

string

Returns

TModule


createComponentLocalizer()

createComponentLocalizer(moduleUrl): LocaleLocalizerDictionary

Defined in: runtime.ts:324

Creates a lazy SFC localizer proxy for component static $l access.

This is primarily used by generated component options.

Parameters

moduleUrl

string

Returns

LocaleLocalizerDictionary


createInternationalization()

createInternationalization(options): InternationalizationInstance

Defined in: runtime.ts:188

Creates a runtime instance from explicit locale loaders and format presets.

Parameters

options

InternationalizationRuntimeOptions

Returns

InternationalizationInstance


defineInternationalization()

defineInternationalization<TMessages>(messages): TMessages

Defined in: runtime.ts:243

Defines programmatic locale dictionaries while preserving literal TypeScript types for downstream extraction and component-level access.

Type Parameters

TMessages

TMessages extends Partial<Record<string, RuntimeLocaleDictionary>>

Parameters

messages

TMessages

Returns

TMessages


formatLocaleMessage()

formatLocaleMessage(message, context?): string

Defined in: message.ts:74

Formats a locale message with either Vue-style or ICU syntax.

Parameters

message

string

context?

LocaleMessageContext = {}

Returns

string


formatLocaleTemplate()

formatLocaleTemplate(template, values?): string

Defined in: runtime.ts:363

Formats a lightweight Vue-style locale template with named values.

Parameters

template

string

values?

LocaleTemplateValues = {}

Returns

string


getLocaleMessageListIndexes()

getLocaleMessageListIndexes(message): number[]

Defined in: message.ts:108

Returns the list interpolation indexes required by a Vue-style message.

Parameters

message

string

Returns

number[]


getLocaleMessageNamedKeys()

getLocaleMessageNamedKeys(message, syntax?): string[]

Defined in: message.ts:89

Returns the named interpolation keys required by a locale message.

Parameters

message

string

syntax?

LocaleMessageSyntax = 'vue'

Returns

string[]


hasLocaleMessagePlural()

hasLocaleMessagePlural(message, syntax?): boolean

Defined in: message.ts:123

Returns whether a locale message contains plural variants.

Parameters

message

string

syntax?

LocaleMessageSyntax = 'vue'

Returns

boolean


isIcuLocaleMessage()

isIcuLocaleMessage(message): boolean

Defined in: message.ts:45

Returns whether a message looks like an ICU plural/select message.

Parameters

message

string

Returns

boolean


setActiveInternationalization()

setActiveInternationalization(instance): void

Defined in: runtime.ts:250

Sets the active instance used outside Vue injection context.

Parameters

instance

InternationalizationInstance

Returns

void


useDateTimeFormat()

useDateTimeFormat(): Readonly<ComputedRef<LocaleDateTimeFormatter>>

Defined in: runtime.ts:343

Returns a formatter for the current locale's date-time presets.

Returns

Readonly<ComputedRef<LocaleDateTimeFormatter>>


useInternationalization()

useInternationalization(): InternationalizationInstance

Defined in: runtime.ts:255

Returns the installed internationalization instance.

Returns

InternationalizationInstance


useLocale()

useLocale<TGlobal, TModule>(moduleUrl): Readonly<ComputedRef<LocaleScope<TGlobal, TModule>>>

Defined in: runtime.ts:271

Returns reactive global and SFC dictionaries for the module identified by moduleUrl.

Type Parameters

TGlobal

TGlobal extends RuntimeLocaleDictionary = RuntimeLocaleDictionary

TModule

TModule extends RuntimeLocaleDictionary = RuntimeLocaleDictionary

Parameters

moduleUrl

string

Returns

Readonly<ComputedRef<LocaleScope<TGlobal, TModule>>>


useLocalizer()

useLocalizer<TGlobal, TModule>(moduleUrl): Readonly<ComputedRef<LocaleLocalizerScope<TGlobal, TModule>>>

Defined in: runtime.ts:281

Returns reactive localizer functions for global and SFC dictionaries.

Type Parameters

TGlobal

TGlobal extends RuntimeLocaleDictionary = RuntimeLocaleDictionary

TModule

TModule extends RuntimeLocaleDictionary = RuntimeLocaleDictionary

Parameters

moduleUrl

string

Returns

Readonly<ComputedRef<LocaleLocalizerScope<TGlobal, TModule>>>


useNumberFormat()

useNumberFormat(): Readonly<ComputedRef<LocaleNumberFormatter>>

Defined in: runtime.ts:353

Returns a formatter for the current locale's number presets.

Returns

Readonly<ComputedRef<LocaleNumberFormatter>>


vueInternationalization()

vueInternationalization(options?): Plugin

Defined in: plugin.ts:91

Creates the Vite plugin that collects SFC locale blocks and script-defined dictionaries, then exposes them through virtual:vite-vue-internationalization.

When options are omitted, the plugin reads the matching vite-vue-internationalization/volar entry from the Vite root tsconfig.json.

Parameters

options?

Partial<VueInternationalizationOptions>

Returns

Plugin

virtual

Variables

currentLocale

const currentLocale: string

Defined in: virtual.d.ts:11

Locale resolved from the current URL query or the primary locale.


defineInternationalization

const defineInternationalization: any

Defined in: virtual.d.ts:15

Defines programmatic locale dictionaries while preserving literal types.


Internationalization

const Internationalization: any

Defined in: virtual.d.ts:13

Component used for slot-based interpolation of locale messages.


locales

const locales: string[]

Defined in: virtual.d.ts:9

Locale codes available in the generated runtime module.


primaryLocale

const primaryLocale: string

Defined in: virtual.d.ts:7

Locale used as the source of generated TypeScript types.

Functions

createComponentLocale()

createComponentLocale<TModule>(moduleUrl): TModule

Defined in: virtual.d.ts:41

Creates a lazy SFC dictionary proxy for component static $locale access.

Type Parameters

TModule

TModule extends RuntimeLocaleDictionary = RuntimeLocaleDictionary

Parameters

moduleUrl

string

Returns

TModule


createComponentLocalizer()

createComponentLocalizer(moduleUrl): LocaleLocalizerDictionary

Defined in: virtual.d.ts:43

Creates a lazy SFC localizer proxy for component static $l access.

Parameters

moduleUrl

string

Returns

LocaleLocalizerDictionary


createInternationalization()

createInternationalization(options?): InternationalizationInstance

Defined in: virtual.d.ts:19

Creates an internationalization instance with generated locale loaders.

Parameters

options?
dateTimeFormats?

any

fallbackLocale?

string

initialLocale?

string

messageSyntax?

any

numberFormats?

any

Returns

InternationalizationInstance


resolveInitialLocale()

resolveInitialLocale(): string

Defined in: virtual.d.ts:17

Resolves the initial locale from the current URL query.

Returns

string


setActiveInternationalization()

setActiveInternationalization(instance): void

Defined in: virtual.d.ts:27

Sets the active instance used outside Vue injection context.

Parameters

instance

InternationalizationInstance

Returns

void


useDateTimeFormat()

useDateTimeFormat(): Readonly<ComputedRef<LocaleDateTimeFormatter>>

Defined in: virtual.d.ts:45

Returns a formatter for the current locale's date-time presets.

Returns

Readonly<ComputedRef<LocaleDateTimeFormatter>>


useInternationalization()

useInternationalization(): InternationalizationInstance

Defined in: virtual.d.ts:29

Returns the installed internationalization instance.

Returns

InternationalizationInstance


useLocale()

useLocale<TGlobal, TModule>(moduleUrl): Readonly<ComputedRef<LocaleScope<TGlobal, TModule>>>

Defined in: virtual.d.ts:31

Returns reactive global and SFC dictionaries for the given module URL.

Type Parameters

TGlobal

TGlobal extends RuntimeLocaleDictionary = RuntimeLocaleDictionary

TModule

TModule extends RuntimeLocaleDictionary = RuntimeLocaleDictionary

Parameters

moduleUrl

string

Returns

Readonly<ComputedRef<LocaleScope<TGlobal, TModule>>>


useLocalizer()

useLocalizer<TGlobal, TModule>(moduleUrl): Readonly<ComputedRef<LocaleLocalizerScope<TGlobal, TModule>>>

Defined in: virtual.d.ts:36

Returns reactive localizer functions for global and SFC dictionaries.

Type Parameters

TGlobal

TGlobal extends RuntimeLocaleDictionary = RuntimeLocaleDictionary

TModule

TModule extends RuntimeLocaleDictionary = RuntimeLocaleDictionary

Parameters

moduleUrl

string

Returns

Readonly<ComputedRef<LocaleLocalizerScope<TGlobal, TModule>>>


useNumberFormat()

useNumberFormat(): Readonly<ComputedRef<LocaleNumberFormatter>>

Defined in: virtual.d.ts:47

Returns a formatter for the current locale's number presets.

Returns

Readonly<ComputedRef<LocaleNumberFormatter>>