# General ## createI18n Vue I18n factory **Signature:** ```typescript export declare function createI18n, LocaleParams> = I18nOptions, LocaleParams>, Messages extends Record = NonNullable extends Record ? NonNullable : {}, DateTimeFormats extends Record = NonNullable extends Record ? NonNullable : {}, NumberFormats extends Record = NonNullable extends Record ? NonNullable : {}, OptionLocale = Options['locale'] extends string ? Options['locale'] : Locale>(options: Options): I18n; ``` ### Type Parameters | Parameter | Description | | --- | --- | | Schema | The i18n resources (messages, datetimeFormats, numberFormats) schema, default | | Locales | The locales of i18n resource schema, default `en-US` | ### Parameters | Parameter | Type | Description | | --- | --- | --- | | options | Options | An options, see the [I18nOptions](general#i18noptions) | ### Returns [I18n](general#i18n) instance See about: - [Getting Started](../../guide/essentials/started) - [Composition API](../../guide/advanced/composition) **Examples** ```js import { createApp } from 'vue' import { createI18n, useI18n } from 'vue-i18n' // call with I18n option const i18n = createI18n({ locale: 'ja', messages: { en: { ... }, ja: { ... } } }) const App = { setup() { // ... const { t } = useI18n({ ... }) return { ... , t } } } const app = createApp(App) // install! app.use(i18n) app.mount('#app') ``` ## DefineDateTimeFormat The type definition of datetime format **Signature:** ```typescript export interface DefineDateTimeFormat extends DateTimeFormat ``` **Details** The typealias is used to strictly define the type of the Datetime format. The type defined by this can be used in the global scope. **Examples** ```ts // type.d.ts (`.d.ts` file at your app) import { DefineDateTimeFormat } from 'vue-i18n' declare module 'vue-i18n' { export interface DefineDateTimeFormat { short: { hour: 'numeric' timezone: string } } } ``` ## DefineLocaleMessage The type definition of Locale Message **Signature:** ```typescript export interface DefineLocaleMessage extends LocaleMessage ``` **Details** The typealias is used to strictly define the type of the Locale message. The type defined by this can be used in the global scope. **Examples** ```ts // type.d.ts (`.d.ts` file at your app) import { DefineLocaleMessage } from 'vue-i18n' declare module 'vue-i18n' { export interface DefineLocaleMessage { title: string menu: { login: string } } } ``` ## DefineNumberFormat The type definition of number format **Signature:** ```typescript export interface DefineNumberFormat extends NumberFormat ``` **Details** The typealias is used to strictly define the type of the Number format. The type defined by this can be used in the global scope. **Examples** ```ts // type.d.ts (`.d.ts` file at your app) import { DefineNumberFormat } from 'vue-i18n' declare module 'vue-i18n' { export interface DefineNumberFormat { currency: { style: 'currency' currencyDisplay: 'symbol' currency: string } } } ``` ## ExportedGlobalComposer Exported global composer instance **Signature:** ```typescript export interface ExportedGlobalComposer ``` **Details** This interface is the [global composer](general#global) that is provided interface that is injected into each component with `app.config.globalProperties`. ### availableLocales Available locales **Signature:** ```typescript readonly availableLocales: Locale[]; ``` **Details** This property is a proxy-like property for `Composer#availableLocales`. About details, see the ### fallbackLocale Fallback locale **Signature:** ```typescript fallbackLocale: FallbackLocale; ``` **Details** This property is a proxy-like property for `Composer#fallbackLocale`. About details, see the ### locale Locale **Signature:** ```typescript locale: Locale; ``` **Details** This property is a proxy-like property for `Composer#locale`. About details, see the ## I18n I18n instance **Signature:** ```typescript export interface I18n = {}, DateTimeFormats extends Record = {}, NumberFormats extends Record = {}, OptionLocale = Locale> ``` **Details** The instance required for installation as the Vue plugin ### global The property accessible to the global Composer instance An instance of this property is **global scope***. **Signature:** ```typescript readonly global: Composer; ``` ### dispose() Release global scope resource **Signature:** ```typescript dispose(): void; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | ### install(app, options) Install entry point **Signature:** ```typescript install(app: App, ...options: unknown[]): void; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | | app | App | A target Vue app instance | | options | unknown[] | An install options | ## I18nAdditionalOptions I18n Additional Options **Signature:** ```typescript export interface I18nAdditionalOptions ``` **Details** `I18nAdditionalOptions` are specific Vue I18n configuration options for plugin installation and behavior control. ### globalInjection Whether to inject global properties & functions into for each component. **Signature:** ```typescript globalInjection?: boolean; ``` **Details** If set to `true`, then properties and methods prefixed with `$` are injected into Vue Component. See about: - [Implicit with injected properties and functions](../../guide/advanced/composition#implicit-with-injected-properties-and-functions) - link ComponentCustomProperties `true` ## I18nOptions I18n Options for `createI18n` **Signature:** ```typescript export type I18nOptions> = I18nAdditionalOptions & Options; ``` ## I18nPluginOptions Vue I18n plugin options **Signature:** ```typescript export interface I18nPluginOptions ``` **Details** An options specified when installing Vue I18n as Vue plugin with using `app.use`. ### globalInstall Whether to globally install the components that is offered by Vue I18n **Signature:** ```typescript globalInstall?: boolean; ``` **Details** If this option is enabled, the components will be installed globally at `app.use` time. If you want to install manually in the `import` syntax, you can set it to `false` to install when needed. `true` ## I18nScope I18n Scope **Signature:** ```typescript export type I18nScope = 'local' | 'parent' | 'global'; ``` ## VERSION Vue I18n Version **Signature:** ```typescript VERSION: string ``` **Details** Semver format. Same format as the package.json `version` field. ## DateTimeOptions DateTime options **Signature:** ```typescript export interface DateTimeOptions extends Intl.DateTimeFormatOptions, LocaleOptions ``` **Details** Options for Datetime formatting API ### fallbackWarn **Signature:** ```typescript fallbackWarn?: boolean; ``` **Details** Whether do resolve on format keys when your language lacks a formatting for a key ### key **Signature:** ```typescript key?: Key; ``` **Details** The target format key ### missingWarn **Signature:** ```typescript missingWarn?: boolean; ``` **Details** Whether suppress warnings outputted when localization fails ### part **Signature:** ```typescript part?: boolean; ``` **Details** Whether to use [Intel.DateTimeFormat#formatToParts](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts) ## DefineCoreLocaleMessage The type definition of Locale Message for `@intlify/core-base` package **Signature:** ```typescript export interface DefineCoreLocaleMessage extends LocaleMessage ``` **Details** The typealias is used to strictly define the type of the Locale message. **Examples** ```ts // type.d.ts (`.d.ts` file at your app) import { DefineCoreLocaleMessage } from '@intlify/core-base' declare module '@intlify/core-base' { export interface DefineCoreLocaleMessage { title: string menu: { login: string } } } ``` ## FallbackLocale **Signature:** ```typescript export type FallbackLocale = Locale | Locale[] | { [locale in string]: Locale[]; } | false; ``` ## fallbackWithLocaleChain Fallback with locale chain **Signature:** ```typescript export declare function fallbackWithLocaleChain(ctx: CoreContext, fallback: FallbackLocale, start: Locale): Locale[]; ``` **Details** A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default. **See Also** - [Fallbacking](../../guide/essentials/fallback) ### Parameters | Parameter | Type | Description | | --- | --- | --- | | ctx | CoreContext<Message> | A [context](#corecontext) | | fallback | FallbackLocale | A [fallback locale](general#fallbacklocale) | | start | Locale | A starting [locale](general#locale) | ### Returns Fallback locales ## fallbackWithSimple Fallback with simple implementation **Signature:** ```typescript export declare function fallbackWithSimple(_ctx: CoreContext, fallback: FallbackLocale, start: Locale): Locale[]; ``` **Details** A fallback locale function implemented with a simple fallback algorithm. Basically, the chain consists of `start` plus the specified fallback: for a string or array `fallbackLocale`, the value as specified in the props is used; for a map `fallbackLocale`, the map's **keys** are used and the `default` key is skipped since it is not a locale name. ### Parameters | Parameter | Type | Description | | --- | --- | --- | | _ctx | CoreContext<Message> | | | fallback | FallbackLocale | A [fallback locale](general#fallbacklocale) | | start | Locale | A starting [locale](general#locale) | ### Returns Fallback locales ## LinkedModifiers **Signature:** ```typescript export type LinkedModifiers = { [key: string]: LinkedModify; }; ``` ## Locale **Signature:** ```typescript export type Locale = IsNever extends true ? string : GeneratedLocale; ``` ## LocaleDetector **Signature:** ```typescript export interface LocaleDetector ``` ### resolvedOnce ### (...args: Args): Locale | Promise<Locale>; ## LocaleFallbacker The locale fallbacker **Signature:** ```typescript export type LocaleFallbacker = (ctx: CoreContext, fallback: FallbackLocale, start: Locale) => Locale[]; ``` ## LocaleMessage **Signature:** ```typescript export type LocaleMessage = Record>; ``` ## LocaleMessageDictionary **Signature:** ```typescript export type LocaleMessageDictionary = { [K in keyof T]: LocaleMessageType; }; ``` ## LocaleMessages **Signature:** ```typescript export type LocaleMessages = LocaleRecord, Schema>; ``` ## LocaleMessageType **Signature:** ```typescript export type LocaleMessageType = T extends string ? string : T extends () => Promise ? LocaleMessageDictionary : T extends (...args: infer Arguments) => any ? (...args: Arguments) => ReturnType : T extends Record ? LocaleMessageDictionary : T extends Array ? { [K in keyof T]: T[K]; } : T; ``` ## LocaleMessageValue **Signature:** ```typescript export type LocaleMessageValue = LocaleMessageDictionary | string; ``` ## LocaleOptions **Signature:** ```typescript export interface LocaleOptions ``` ### locale **Signature:** ```typescript locale?: Locales | LocaleDetector; ``` **Details** The locale of localization ## MessageCompiler The message compiler **Signature:** ```typescript export type MessageCompiler = (message: MessageSource, context: MessageCompilerContext) => MessageFunction; ``` ## MessageCompilerContext The context that will pass the message compiler. **Signature:** ```typescript export type MessageCompilerContext = Pick & { warnHtmlMessage?: boolean; key: string; locale: Locale; }; ``` ## MessageContext The message context. **Signature:** ```typescript export interface MessageContext ``` ### type The message type to be handled by the message function. **Signature:** ```typescript type: string; ``` **Details** Usually `text`, you need to return **string** in message function. ### values The message values. **Signature:** ```typescript values: Record; ``` **Details** The message values are the argument values passed from translation function, such as `$t`, `t`, or `translate`. **Examples** vue-i18n `$t` (or `t`) case: ```html

{{ $t('greeting', { name: 'DIO' }) }}

``` `@intlify/core` (`@intlify/core-base`) `translate` case: ```js translate(context, 'foo.bar', ['dio']) // `['dio']` is message values ``` ### linked(key, modifier) Resolve linked message. **Signature:** ```typescript linked(key: Path, modifier?: string): MessageType; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | | key | Path | A message key | | modifier | string | A modifier | #### Returns A resolve message. ### linked(key, modifier, type) Overloaded `linked` **Signature:** ```typescript linked(key: Path, modifier?: string, type?: string): MessageType; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | | key | Path | A message key | | modifier | string | A modifier | | type | string | A message type | #### Returns A resolve message. ### linked(key, options) Overloaded `linked` **Signature:** ```typescript linked(key: Path, options?: LinkedOptions): MessageType; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | | key | Path | A message key | | options | LinkedOptions | An [linked options](#linkedoptions) | #### Returns A resolve message. ### list(index) Resolve message value from list. **Signature:** ```typescript list(index: number): unknown; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | | index | number | An index of message values. | #### Returns A resolved message value. **Examples** ```js const messages = { en: { greeting: ({ list }) => `hello, ${list(0)}!` } } ``` ### named(key) Resolve message value from named. **Signature:** ```typescript named(key: string): unknown; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | | key | string | A key of message value. | #### Returns A resolved message value. **Examples** ```js const messages = { en: { greeting: ({ named }) => `hello, ${named('name')}!` } } ``` ### plural(messages) Resolve message with plural index. **Signature:** ```typescript plural(messages: T[]): T; ``` **Details** That's resolved with plural index with translation function. #### Parameters | Parameter | Type | Description | | --- | --- | --- | | messages | T[] | the messages, that is resolved with plural index with translation function. | #### Returns A resolved message. **Examples** ```js const messages = { en: { car: ({ plural }) => plural(['car', 'cars']), apple: ({ plural, named }) => plural([ 'no apples', 'one apple', `${named('count')} apples` ]) } } ``` ## MessageFunction The Message Function. **Signature:** ```typescript export type MessageFunction = MessageFunctionCallable | MessageFunctionInternal; ``` ## MessageFunctionReturn **Signature:** ```typescript export type MessageFunctionReturn = T extends string ? MessageType : MessageType[]; ``` ## MessageResolver **Signature:** ```typescript export type MessageResolver = (obj: unknown, path: Path) => PathValue; ``` ## NamedValue **Signature:** ```typescript export type NamedValue = T & Record; ``` ## NumberOptions Number Options **Signature:** ```typescript export interface NumberOptions extends Intl.NumberFormatOptions, LocaleOptions ``` **Details** Options for Number formatting API ### fallbackWarn **Signature:** ```typescript fallbackWarn?: boolean; ``` **Details** Whether do resolve on format keys when your language lacks a formatting for a key ### key **Signature:** ```typescript key?: Key; ``` **Details** The target format key ### missingWarn **Signature:** ```typescript missingWarn?: boolean; ``` **Details** Whether suppress warnings outputted when localization fails ### part **Signature:** ```typescript part?: boolean; ``` **Details** Whether to use [Intel.NumberFormat#formatToParts](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts) ## Path **Signature:** ```typescript export type Path = string; ``` ## PathValue **Signature:** ```typescript export type PathValue = string | number | boolean | Function | null | { [key: string]: PathValue; } | PathValue[]; ``` ## PluralizationRules **Signature:** ```typescript export type PluralizationRules = { [locale: string]: PluralizationRule; }; ``` ## PostTranslationHandler **Signature:** ```typescript export type PostTranslationHandler = (translated: MessageFunctionReturn, key: string) => MessageFunctionReturn; ``` ## registerLocaleFallbacker Register the locale fallbacker **Signature:** ```typescript export declare function registerLocaleFallbacker(fallbacker: LocaleFallbacker): void; ``` ### Parameters | Parameter | Type | Description | | --- | --- | --- | | fallbacker | LocaleFallbacker | A [LocaleFallbacker](general#localefallbacker) function | ## registerMessageResolver Register the message resolver **Signature:** ```typescript export declare function registerMessageResolver(resolver: MessageResolver): void; ``` ### Parameters | Parameter | Type | Description | | --- | --- | --- | | resolver | MessageResolver | A [MessageResolver](general#messageresolver) function | ## resolveValue message resolver **Signature:** ```typescript export declare function resolveValue(obj: unknown, path: Path): PathValue; ``` **Details** Resolves messages. messages with a hierarchical structure such as objects can be resolved. This resolver is used in VueI18n as default. ### Parameters | Parameter | Type | Description | | --- | --- | --- | | obj | unknown | A target object to be resolved with path | | path | Path | A [path](general#path) to resolve the value of message | ### Returns A resolved [path value](general#pathvalue) ## resolveWithKeyValue key-value message resolver **Signature:** ```typescript export declare function resolveWithKeyValue(obj: unknown, path: Path): PathValue; ``` **Details** Resolves messages with the key-value structure. Note that messages with a hierarchical structure such as objects cannot be resolved ### Parameters | Parameter | Type | Description | | --- | --- | --- | | obj | unknown | A target object to be resolved with path | | path | Path | A [path](general#path) to resolve the value of message | ### Returns A resolved [path value](general#pathvalue) ## TranslateOptions Translate Options **Signature:** ```typescript export interface TranslateOptions extends LocaleOptions ``` **Details** Options for Translation API ### default **Signature:** ```typescript default?: string | boolean; ``` **Details** Default message when is occurred translation missing ### escapeParameter **Signature:** ```typescript escapeParameter?: boolean; ``` **Details** Whether do escape parameter for list or named interpolation values ### fallbackWarn **Signature:** ```typescript fallbackWarn?: boolean; ``` **Details** Whether do template interpolation on translation keys when your language lacks a translation for a key ### list **Signature:** ```typescript list?: unknown[]; ``` **Details** List interpolation ### missingWarn **Signature:** ```typescript missingWarn?: boolean; ``` **Details** Whether suppress warnings outputted when localization fails ### named **Signature:** ```typescript named?: NamedValue; ``` **Details** Named interpolation ### plural **Signature:** ```typescript plural?: number; ``` **Details** Plulralzation choice number ### resolvedMessage **Signature:** ```typescript resolvedMessage?: boolean; ``` **Details** Whether the message has been resolved