diff --git a/.gitignore b/.gitignore index 92f077338..8d301cd4c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ dist -docs/api/*.md -!docs/api/injection.md +docs/api/v11/*.md +!docs/api/v11/injection.md packages/vue-i18n/index.html temp coverage diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index b4f5f48b9..662190b6e 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -46,6 +46,8 @@ export default defineConfig({ sidebar: { '/guide/': sidebarGuide(), '/api/': sidebarApi(), + // NOTE: if we need to support multiple versions, we can be enble the following sidebar items + // '/api/v11/': sidebarApi('v11/'), '/ecosystem/': sidebarEcosystem() } } @@ -59,7 +61,9 @@ function nav() { }, { text: 'API', - link: '/api/general' + link: '/api/general', + // NOTE: if we need to support multiple versions, we can be enble the following navigation items + // items: [{ text: 'latest', link: '/api/general' }, { text: 'v9 ~ v11', link: '/api/v11/general' }] }, { text: 'Ecosystem', @@ -241,34 +245,34 @@ function sidebarGuide() { ] } -function sidebarApi() { +function sidebarApi(ns = '') { return [ { text: 'API Reference', items: [ { text: 'General', - link: '/api/general' + link: `/api/${ns}general` }, { text: 'Legacy API', - link: '/api/legacy' + link: `/api/${ns}legacy` }, { text: 'Composition API', - link: '/api/composition' + link: `/api/${ns}composition` }, { text: 'Components', - link: '/api/component' + link: `/api/${ns}component` }, { text: 'Directives', - link: '/api/directive' + link: `/api/${ns}directive` }, { text: 'Component Injections', - link: '/api/injection' + link: `/api/${ns}injection` } ] } diff --git a/docs/api/component.md b/docs/api/component.md new file mode 100644 index 000000000..0886ff174 --- /dev/null +++ b/docs/api/component.md @@ -0,0 +1,279 @@ +# Components + +## BaseFormatProps + +BaseFormat Props for Components that is offered Vue I18n + +**Signature:** +```typescript +export interface BaseFormatProps +``` + +**Details** + +The interface definitions of the underlying props of components such as Translation, DatetimeFormat, and NumberFormat. + +### i18n + +**Signature:** +```typescript +i18n?: Composer; +``` + +**Details** + +A composer instance with an existing scope. + +This option takes precedence over the `scope` option. + +### locale + +**Signature:** +```typescript +locale?: Locale; +``` + +**Details** + +Specifies the locale to be used for the component. + +If specified, the global scope or the locale of the parent scope of the target component will not be overridden and the specified locale will be used. + +### scope + +**Signature:** +```typescript +scope?: ComponentI18nScope; +``` + +**Details** + +Specifies the scope to be used in the target component. + +You can specify either `global` or `parent`. + +If `global` is specified, global scope is used, else then `parent` is specified, the scope of the parent of the target component is used. + +If the parent is a global scope, the global scope is used, if it's a local scope, the local scope is used. + +### tag + +**Signature:** +```typescript +tag?: string | object; +``` + +**Details** + +Used to wrap the content that is distribute in the slot. If omitted, the slot content is treated as Fragments. + +You can specify a string-based tag name, such as `p`, or the object for which the component is defined. + +## DatetimeFormat + +Datetime Format Component + +**Signature:** +```typescript +DatetimeFormat: { + new (): { + $props: VNodeProps & DatetimeFormatProps & BaseFormatProps; + }; +} +``` + +**Details** + +See the following items for property about details + +:::danger +Not supported IE, due to no support `Intl.DateTimeFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts) + +If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-datetimeformat) +::: + +**See Also** +- [FormattableProps](component#formattableprops) +- [BaseFormatProps](component#baseformatprops) +- [Custom Formatting](../guide/essentials/datetime#custom-formatting) + +## DatetimeFormatProps + +DatetimeFormat Component Props + +**Signature:** +```typescript +export type DatetimeFormatProps = FormattableProps; +``` + +## FormattableProps + +Formattable Props + +**Signature:** +```typescript +export interface FormattableProps extends BaseFormatProps +``` + +**Details** + +The props used in DatetimeFormat, or NumberFormat component + +### format + +**Signature:** +```typescript +format?: string | Format; +``` + +**Details** + +The format to use in the target component. + +Specify the format key string or the format as defined by the Intl API in ECMA 402. + +### value + +**Signature:** +```typescript +value: Value; +``` + +**Details** + +The value specified for the target component + +## NumberFormat + +Number Format Component + +**Signature:** +```typescript +NumberFormat: { + new (): { + $props: VNodeProps & NumberFormatProps & BaseFormatProps; + }; +} +``` + +**Details** + +See the following items for property about details + +:::danger +Not supported IE, due to no support `Intl.NumberFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts) + +If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-numberformat) +::: + +**See Also** +- [FormattableProps](component#formattableprops) +- [BaseFormatProps](component#baseformatprops) +- [Custom Formatting](../guide/essentials/number#custom-formatting) + +## NumberFormatProps + +NumberFormat Component Props + +**Signature:** +```typescript +export type NumberFormatProps = FormattableProps; +``` + +## Translation + +Translation Component + +**Signature:** +```typescript +Translation: { + new (): { + $props: VNodeProps & TranslationProps; + }; +} +``` + +**Details** + +See the following items for property about details + +**See Also** +- [TranslationProps](component#translationprops) +- [BaseFormatProps](component#baseformatprops) +- [Component Interpolation](../guide/advanced/component) + +**Examples** + + +```html +
+ + + {{ $t('tos') }} + + +
+``` + + +```js +import { createApp } from 'vue' +import { createI18n } from 'vue-i18n' + +const messages = { + en: { + tos: 'Term of Service', + term: 'I accept xxx {0}.' + }, + ja: { + tos: '利用規約', + term: '私は xxx の{0}に同意します。' + } +} + +const i18n = createI18n({ + locale: 'en', + messages +}) + +const app = createApp({ + data: { + url: '/term' + } +}).use(i18n).mount('#app') +``` + + + + +## TranslationProps + +Translation Component Props + +**Signature:** +```typescript +export interface TranslationProps extends BaseFormatProps +``` + +### keypath + +**Signature:** +```typescript +keypath: string; +``` + +**Details** + +The locale message key can be specified prop + +### plural + +**Signature:** +```typescript +plural?: number | string; +``` + +**Details** + +The Plural Choosing the message number prop + diff --git a/docs/api/composition.md b/docs/api/composition.md new file mode 100644 index 000000000..b3360f07b --- /dev/null +++ b/docs/api/composition.md @@ -0,0 +1,2176 @@ +# Composition API + +## Composer + +Composer interfaces + +**Signature:** +```typescript +export interface Composer = {}, DateTimeFormats extends Record = {}, NumberFormats extends Record = {}, OptionLocale = Locale, ResourceLocales = PickupLocales> | PickupLocales> | PickupLocales>, Locales = Locale extends GeneratedLocale ? GeneratedLocale : OptionLocale extends Locale ? IsNever extends true ? Locale : ResourceLocales : OptionLocale | ResourceLocales> extends ComposerCustom +``` + +**Details** + +This is the interface for being used for Vue 3 Composition API. + +### availableLocales + +**Signature:** +```typescript +readonly availableLocales: Locales[]; +``` + +**Details** + +The list of available locales in `messages` in lexical order. + +### d + +Datetime formatting + +**Signature:** +```typescript +d: ComposerDateTimeFormatting>; +``` + +**Details** + +About details functions, See the [ComposerDateTimeFormatting](composition#composerdatetimeformatting) + +### datetimeFormats + +**Signature:** +```typescript +readonly datetimeFormats: ComputedRef<{ + [K in keyof DateTimeFormats]: DateTimeFormats[K]; + }>; +``` + +**Details** + +The datetime formats of localization. + +**See Also** +- [Datetime Formatting](../guide/essentials/datetime) + +### escapeParameter + +**Signature:** +```typescript +escapeParameter: boolean; +``` + +**Details** + +Whether interpolation parameters are escaped before the message is translated. + +**See Also** +- [HTML Message](../guide/essentials/syntax#html-message) + +### fallbackFormat + +**Signature:** +```typescript +fallbackFormat: boolean; +``` + +**Details** + +Whether suppress warnings when falling back to either `fallbackLocale` or root. + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### fallbackLocale + +**Signature:** +```typescript +fallbackLocale: WritableComputedRef>; +``` + +**Details** + +The current fallback locales this Composer instance is using. + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### fallbackRoot + +**Signature:** +```typescript +fallbackRoot: boolean; +``` + +**Details** + +Whether to fall back to root level (global scope) localization when localization fails. + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### fallbackWarn + +**Signature:** +```typescript +fallbackWarn: boolean | RegExp; +``` + +**Details** + +Whether suppress fall back warnings when localization fails. + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### id + +**Signature:** +```typescript +id: number; +``` + +**Details** + +Instance ID. + +### inheritLocale + +**Signature:** +```typescript +inheritLocale: boolean; +``` + +**Details** + +Whether inherit the root level locale to the component localization locale. + +**See Also** +- [Local Scope](../guide/essentials/scope#local-scope-2) + +### isGlobal + +**Signature:** +```typescript +readonly isGlobal: boolean; +``` + +**Details** + +Whether this composer instance is global or not + +### locale + +**Signature:** +```typescript +locale: WritableComputedRef; +``` + +**Details** + +The current locale this Composer instance is using. + +If the locale contains a territory and a dialect, this locale contains an implicit fallback. + +**See Also** +- [Scope and Locale Changing](../guide/essentials/scope) + +### messages + +**Signature:** +```typescript +readonly messages: ComputedRef<{ + [K in keyof Messages]: Messages[K]; + }>; +``` + +**Details** + +The locale messages of localization. + +**See Also** +- [Getting Started](../guide/essentials/started) + +### missingWarn + +**Signature:** +```typescript +missingWarn: boolean | RegExp; +``` + +**Details** + +Whether suppress warnings outputted when localization fails. + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### modifiers + +**Signature:** +```typescript +readonly modifiers: LinkedModifiers; +``` + +**Details** + +Custom Modifiers for linked messages. + +**See Also** +- [Custom Modifiers](../guide/essentials/syntax#custom-modifiers) + +### n + +Number Formatting + +**Signature:** +```typescript +n: ComposerNumberFormatting>; +``` + +**Details** + +About details functions, See the [ComposerNumberFormatting](composition#composernumberformatting) + +### numberFormats + +**Signature:** +```typescript +readonly numberFormats: ComputedRef<{ + [K in keyof NumberFormats]: NumberFormats[K]; + }>; +``` + +**Details** + +The number formats of localization. + +**See Also** +- [Number Formatting](../guide/essentials/number) + +### pluralRules + +**Signature:** +```typescript +readonly pluralRules: PluralizationRules; +``` + +**Details** + +A set of rules for word pluralization + +**See Also** +- [Custom Pluralization](../guide/essentials/pluralization#custom-pluralization) + +### rt + +Resolve locale message translation + +**Signature:** +```typescript +rt: ComposerResolveLocaleMessageTranslation; +``` + +**Details** + +About details functions, See the [ComposerResolveLocaleMessageTranslation](composition#composerresolvelocalemessagetranslation) + +### t + +Locale message translation + +**Signature:** +```typescript +t: ComposerTranslation>; +``` + +**Details** + +About details functions, See the [ComposerTranslation](composition#composertranslation) + +### warnHtmlMessage + +**Signature:** +```typescript +warnHtmlMessage: boolean; +``` + +**Details** + +Whether to allow the use locale messages of HTML formatting. + +If you set `false`, will check the locale messages on the Composer instance. + +If you are specified `true`, a warning will be output at console. + +**See Also** +- [HTML Message](../guide/essentials/syntax#html-message) +- [Change `warnHtmlInMessage` option default value](../guide/migration/breaking#change-warnhtmlinmessage-option-default-value) + +### getDateTimeFormat(locale) + +Get datetime format + +**Signature:** +```typescript +getDateTimeFormat = never, LocaleSchema extends string = string, Locale extends PickupLocales> = PickupLocales>, Return = IsNever extends true ? IsEmptyObject extends true ? RemoveIndexSignature<{ + [K in keyof DefineDateTimeFormat]: DefineDateTimeFormat[K]; + }> : NonNullable[Locale] : DateTimeSchema>(locale: LocaleSchema | Locale): Return; +``` + +#### Type Parameters + +| Parameter | Description | +| --- | --- | +| DateTimeSchema | The datetime format schema, default `never` | + +**Details** + +get datetime format from Composer instance [datetimeFormats](composition#datetimeformats). + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| locale | LocaleSchema | Locale | A target locale | + +#### Returns + + Datetime format + +### getLocaleMessage(locale) + +Get locale message + +**Signature:** +```typescript +getLocaleMessage = never, LocaleSchema extends string = string, Locale extends PickupLocales> = PickupLocales>, Return = IsNever extends true ? IsEmptyObject extends true ? RemoveIndexSignature<{ + [K in keyof DefineLocaleMessage]: DefineLocaleMessage[K]; + }> : NonNullable[Locale] : MessageSchema>(locale: LocaleSchema | Locale): Return; +``` + +#### Type Parameters + +| Parameter | Description | +| --- | --- | +| MessageSchema | The locale message schema, default `never` | + +**Details** + +get locale message from Composer instance [messages](composition#messages). + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| locale | LocaleSchema | Locale | A target locale | + +#### Returns + + Locale messages + +### getMissingHandler() + +Get missing handler + +**Signature:** +```typescript +getMissingHandler(): MissingHandler | null; +``` + +**See Also** +- [missing](composition#missing) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | + +#### Returns + + [MissingHandler](composition#missinghandler) + +### getNumberFormat(locale) + +Get number format + +**Signature:** +```typescript +getNumberFormat = never, LocaleSchema extends string = string, Locale extends PickupLocales> = PickupLocales>, Return = IsNever extends true ? IsEmptyObject extends true ? RemoveIndexSignature<{ + [K in keyof DefineNumberFormat]: DefineNumberFormat[K]; + }> : NonNullable[Locale] : NumberSchema>(locale: LocaleSchema | Locale): Return; +``` + +#### Type Parameters + +| Parameter | Description | +| --- | --- | +| NumberSchema | The number format schema, default `never` | + +**Details** + +get number format from Composer instance [numberFormats](composition#numberFormats). + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| locale | LocaleSchema | Locale | A target locale | + +#### Returns + + Number format + +### getPostTranslationHandler() + +Get post translation handler + +**Signature:** +```typescript +getPostTranslationHandler(): PostTranslationHandler | null; +``` + +**See Also** +- [missing](composition#posttranslation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | + +#### Returns + + + +### mergeDateTimeFormat(locale, format) + +Merge datetime format + +**Signature:** +```typescript +mergeDateTimeFormat = never, LocaleSchema extends string = string, Locale extends PickupLocales> = PickupLocales>, Formats = IsNever extends true ? Record : DateTimeSchema>(locale: LocaleSchema | Locale, format: Formats): void; +``` + +#### Type Parameters + +| Parameter | Description | +| --- | --- | +| DateTimeSchema | The datetime format schema, default `never` | + +**Details** + +Merge datetime format to Composer instance [datetimeFormats](composition#datetimeformats). + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| locale | LocaleSchema | Locale | A target locale | +| format | Formats | A target datetime format | + +### mergeLocaleMessage(locale, message) + +Merge locale message + +**Signature:** +```typescript +mergeLocaleMessage = never, LocaleSchema extends string = string, Locale extends PickupLocales> = PickupLocales>, Message = IsNever extends true ? Record : MessageSchema>(locale: LocaleSchema | Locale, message: Message): void; +``` + +#### Type Parameters + +| Parameter | Description | +| --- | --- | +| MessageSchema | The locale message schema, default `never` | + +**Details** + +Merge locale message to Composer instance [messages](composition#messages). + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| locale | LocaleSchema | Locale | A target locale | +| message | Message | A message | + +### mergeNumberFormat(locale, format) + +Merge number format + +**Signature:** +```typescript +mergeNumberFormat = never, LocaleSchema extends string = string, Locale extends PickupLocales> = PickupLocales>, Formats = IsNever extends true ? Record : NumberSchema>(locale: LocaleSchema | Locale, format: Formats): void; +``` + +#### Type Parameters + +| Parameter | Description | +| --- | --- | +| NumberSchema | The number format schema, default `never` | + +**Details** + +Merge number format to Composer instance [numberFormats](composition#numberFormats). + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| locale | LocaleSchema | Locale | A target locale | +| format | Formats | A target number format | + +### setDateTimeFormat(locale, format) + +Set datetime format + +**Signature:** +```typescript +setDateTimeFormat = never, LocaleSchema extends string = string, Locale extends PickupLocales> = PickupLocales>, FormatsType = IsNever extends true ? IsEmptyObject extends true ? RemoveIndexSignature<{ + [K in keyof DefineDateTimeFormat]: DefineDateTimeFormat[K]; + }> : NonNullable[Locale] : DateTimeSchema, Formats extends FormatsType = FormatsType>(locale: LocaleSchema | Locale, format: Formats): void; +``` + +#### Type Parameters + +| Parameter | Description | +| --- | --- | +| DateTimeSchema | The datetime format schema, default `never` | + +**Details** + +Set datetime format to Composer instance [datetimeFormats](composition#datetimeformats). + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| locale | LocaleSchema | Locale | A target locale | +| format | Formats | A target datetime format | + +### setLocaleMessage(locale, message) + +Set locale message + +**Signature:** +```typescript +setLocaleMessage = never, LocaleSchema extends string = string, Locale extends PickupLocales> = PickupLocales>, MessageType = IsNever extends true ? IsEmptyObject extends true ? RemoveIndexSignature<{ + [K in keyof DefineLocaleMessage]: DefineLocaleMessage[K]; + }> : NonNullable[Locale] : MessageSchema, Message extends MessageType = MessageType>(locale: LocaleSchema | Locale, message: Message): void; +``` + +#### Type Parameters + +| Parameter | Description | +| --- | --- | +| MessageSchema | The locale message schema, default `never` | + +**Details** + +Set locale message to Composer instance [messages](composition#messages). + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| locale | LocaleSchema | Locale | A target locale | +| message | Message | A message | + +### setMissingHandler(handler) + +Set missing handler + +**Signature:** +```typescript +setMissingHandler(handler: MissingHandler | null): void; +``` + +**See Also** +- [missing](composition#missing) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| handler | MissingHandler | null | A [MissingHandler](composition#missinghandler) | + +### setNumberFormat(locale, format) + +Set number format + +**Signature:** +```typescript +setNumberFormat = never, LocaleSchema extends string = string, Locale extends PickupLocales> = PickupLocales>, FormatsType = IsNever extends true ? IsEmptyObject extends true ? RemoveIndexSignature<{ + [K in keyof DefineNumberFormat]: DefineNumberFormat[K]; + }> : NonNullable[Locale] : NumberSchema, Formats extends FormatsType = FormatsType>(locale: LocaleSchema | Locale, format: Formats): void; +``` + +#### Type Parameters + +| Parameter | Description | +| --- | --- | +| NumberSchema | The number format schema, default `never` | + +**Details** + +Set number format to Composer instance [numberFormats](composition#numberFormats). + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| locale | LocaleSchema | Locale | A target locale | +| format | Formats | A target number format | + +### setPostTranslationHandler(handler) + +Set post translation handler + +**Signature:** +```typescript +setPostTranslationHandler(handler: PostTranslationHandler | null): void; +``` + +**See Also** +- [missing](composition#posttranslation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| handler | PostTranslationHandler<VueMessageType> | null | A | + +### te(key, locale) + +Translation locale message exist + +**Signature:** +```typescript +te = PickupKeys>(key: Str | Key, locale?: Locales): boolean; +``` + +**Details** + +whether do exist locale message on Composer instance [messages](composition#messages). + +If you specified `locale`, check the locale messages of `locale`. + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Str | Key | A target locale message key | +| locale | Locales | A locale, it will be used over than global scope or local scope | + +#### Returns + + If found locale message, `true`, else `false`, Note that `false` is returned even if the value present in the key is not translatable, yet if `translateExistCompatible` is set to `true`, it will return `true` if the key is available, even if the value is not translatable. + +### tm(key) + +Locale messages getter + +**Signature:** +```typescript +tm = PickupKeys, Locale extends PickupLocales> = PickupLocales>, Target = IsEmptyObject extends false ? NonNullable[Locale] : RemoveIndexSignature<{ + [K in keyof DefineLocaleMessage]: DefineLocaleMessage[K]; + }>, Return = ResourceKeys extends ResourcePath ? ResourceValue : Record>(key: Key | ResourceKeys): Return; +``` + +**Details** + +If [UseI18nScope](general#usei18nscope) `'local'` or Some [UseI18nOptions](composition#usei18noptions) are specified at `useI18n`, it’s translated in preferentially local scope locale messages than global scope locale messages. + +Based on the current `locale`, locale messages will be returned from Composer instance messages. + +If you change the `locale`, the locale messages returned will also correspond to the locale. + +If there are no locale messages for the given `key` in the composer instance messages, they will be returned with [fallbacking](../guide/essentials/fallback). + +:::warning +You need to use `rt` for the locale message returned by `tm`. see the [rt](composition#rt-message) details. +::: + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | A target locale message key + + Locale messages | + +**Examples** + +template block: +```html +
+ +
+``` + +script block: +```js +import { defineComponent } from 'vue +import { useI18n } from 'vue-i18n' + +export default defineComponent({ + setup() { + const { rt, tm } = useI18n({ + messages: { + en: { + contents: [ + { + title: 'Title1', + // ... + paragraphs: [ + // ... + ] + } + ] + } + } + // ... + }) + // ... + return { ... , rt, tm } + } +}) +``` + + + + +## ComposerAdditionalOptions + +Composer additional options for `useI18n` + +**Signature:** +```typescript +export interface ComposerAdditionalOptions +``` + +**Details** + +`ComposerAdditionalOptions` is extend for [ComposerOptions](composition#composeroptions), so you can specify these options. + +**See Also** +- [useI18n](composition#usei18n) + +### useScope + +## ComposerCustom + +The type custom definition of Composer + +**Signature:** +```typescript +export interface ComposerCustom +``` + +**Details** + +The interface that can extend Composer. + +The type defined by 3rd party (e.g. nuxt/i18n) + +**Examples** + + +```ts +// vue-i18n.d.ts (`.d.ts` file at your app) + +declare module 'vue-i18n' { + interface ComposerCustom { + localeCodes: string[] + } +} +``` + + + + +## ComposerDateTimeFormatting + +Datetime formatting functions + +**Signature:** +```typescript +export interface ComposerDateTimeFormatting = {}, Locales = 'en-US', DefinedDateTimeFormat extends RemovedIndexResources = RemovedIndexResources, C = IsEmptyObject extends false ? PickupFormatPathKeys<{ + [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K]; +}> : never, M = IsEmptyObject extends false ? PickupFormatKeys : never, ResourceKeys extends C | M = IsNever extends false ? IsNever extends false ? C | M : C : IsNever extends false ? M : never> +``` + +**Details** + +This is the interface for [Composer](composition#composer) + +### (value: number | Date | string): string; + +Datetime formatting + +**Signature:** +```typescript +(value: number | Date | string): string; +``` + +**Details** + +If this is used in a reactive context, it will re-evaluate once the locale changes. + +If [UseI18nScope](general#usei18nscope) `'local'` or Some [UseI18nOptions](composition#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 datetime formats. + +**See Also** +- [Datetime formatting](../guide/essentials/datetime) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | Date | string | A value, timestamp number or `Date` instance or ISO 8601 string | + +#### Returns + + Formatted value + +### (value: Value, keyOrOptions: Key | ResourceKeys | DateTimeOptions<Key | ResourceKeys, Locales>): string; + +Datetime formatting + +**Signature:** +```typescript +(value: Value, keyOrOptions: Key | ResourceKeys | DateTimeOptions): string; +``` + +**Details** + +Overloaded `d`. About details, see the [call signature](composition#value-number-date-string-string) details. + +In this overloaded `d`, format in datetime format for a key registered in datetime formats. + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | Value | A value, timestamp number or `Date` instance or ISO 8601 string | +| keyOrOptions | Key | ResourceKeys | DateTimeOptions<Key | ResourceKeys, Locales> | A key of datetime formats, or additional for datetime formatting | + +#### Returns + + Formatted value + +### (value: Value, keyOrOptions: Key | ResourceKeys | DateTimeOptions<Key | ResourceKeys, Locales>, locale: Locales): string; + +Datetime formatting + +**Signature:** +```typescript +(value: Value, keyOrOptions: Key | ResourceKeys | DateTimeOptions, locale: Locales): string; +``` + +**Details** + +Overloaded `d`. About details, see the [call signature](composition#value-number-date-string-string) details. + +In this overloaded `d`, format in datetime format for a key registered in datetime formats at target locale + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | Value | A value, timestamp number or `Date` instance or ISO 8601 string | +| keyOrOptions | Key | ResourceKeys | DateTimeOptions<Key | ResourceKeys, Locales> | A key of datetime formats, or additional for datetime formatting | +| locale | Locales | A locale, it will be used over than global scope or local scope. | + +#### Returns + + Formatted value + +## ComposerNumberFormatting + +Number formatting functions + +**Signature:** +```typescript +export interface ComposerNumberFormatting = {}, Locales = 'en-US', DefinedNumberFormat extends RemovedIndexResources = RemovedIndexResources, C = IsEmptyObject extends false ? PickupFormatPathKeys<{ + [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K]; +}> : never, M = IsEmptyObject extends false ? PickupFormatKeys : never, ResourceKeys extends C | M = IsNever extends false ? IsNever extends false ? C | M : C : IsNever extends false ? M : never> +``` + +**Details** + +This is the interface for [Composer](composition#composer) + +### (value: number): string; + +Number Formatting + +**Signature:** +```typescript +(value: number): string; +``` + +**Details** + +If this is used in a reactive context, it will re-evaluate once the locale changes. + +If [UseI18nScope](general#usei18nscope) `'local'` or Some [UseI18nOptions](composition#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 Also** +- [Number formatting](../guide/essentials/number) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | A number value | + +#### Returns + + Formatted value + +### (value: number, keyOrOptions: Key | ResourceKeys | NumberOptions<Key | ResourceKeys, Locales>): string; + +Number Formatting + +**Signature:** +```typescript +(value: number, keyOrOptions: Key | ResourceKeys | NumberOptions): string; +``` + +**Details** + +Overloaded `n`. About details, see the [call signature](composition#value-number-string) details. + +In this overloaded `n`, format in number format for a key registered in number formats. + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | A number value | +| keyOrOptions | Key | ResourceKeys | NumberOptions<Key | ResourceKeys, Locales> | A key of number formats, or additional for number formatting | + +#### Returns + + Formatted value + +### (value: number, keyOrOptions: Key | ResourceKeys | NumberOptions<Key | ResourceKeys, Locales>, locale: Locales): string; + +Number Formatting + +**Signature:** +```typescript +(value: number, keyOrOptions: Key | ResourceKeys | NumberOptions, locale: Locales): string; +``` + +**Details** + +Overloaded `n`. About details, see the [call signature](composition#value-number-string) details. + +In this overloaded `n`, format in number format for a key registered in number formats at target locale. + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | A number value | +| keyOrOptions | Key | ResourceKeys | NumberOptions<Key | ResourceKeys, Locales> | A key of number formats, or additional for number formatting | +| locale | Locales | A locale, it will be used over than global scope or local scope. | + +#### Returns + + Formatted value + +## ComposerOptions + +Composer Options + +**Signature:** +```typescript +export interface ComposerOptions = LocaleMessages, _DateTimeFormats extends DateTimeFormatsType = DateTimeFormatsType, _NumberFormats extends NumberFormatsType = NumberFormatsType> +``` + +**Details** + +This is options to create composer. + +### datetime + +### datetimeFormats + +### escapeParameter + +**Signature:** +```typescript +escapeParameter?: boolean; +``` + +**Details** + +If `escapeParameter` is configured as true then interpolation parameters are escaped before the message is translated. + +This is useful when translation output is used in `v-html` and the translation resource contains html markup (e.g. around a user provided value). + +This usage pattern mostly occurs when passing precomputed text strings into UI components. + +The escape process involves replacing the following symbols with their respective HTML character entities: `<`, `>`, `"`, `'`. + +Setting `escapeParameter` as true should not break existing functionality but provides a safeguard against a subtle type of XSS attack vectors. + +**Default Value** + +`false` + +**See Also** +- [HTML Message](../guide/essentials/syntax#html-message) + +### fallbackFormat + +**Signature:** +```typescript +fallbackFormat?: boolean; +``` + +**Details** + +Whether do template interpolation on translation keys when your language lacks a translation for a key. + +If `true`, skip writing templates for your "base" language; the keys are your templates. + +**Default Value** + +`false` + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### fallbackLocale + +**Signature:** +```typescript +fallbackLocale?: FallbackLocale; +``` + +**Details** + +The locale of fallback localization. + +For more complex fallback definitions see fallback. + +**Default Value** + +The default `'en-US'` for the `locale` if it's not specified, or it's `locale` value + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### fallbackRoot + +**Signature:** +```typescript +fallbackRoot?: boolean; +``` + +**Details** + +In the component localization, whether to fallback to root level (global scope) localization when localization fails. + +If `false`, it's not fallback to root. + +**Default Value** + +`true` + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### fallbackWarn + +**Signature:** +```typescript +fallbackWarn?: boolean | RegExp; +``` + +**Details** + +Whether suppress warnings when falling back to either `fallbackLocale` or root. + +If `false`, suppress fall back warnings. + +If you use regular expression, you can suppress fallback warnings that it match with translation key (e.g. `t`). + +**Default Value** + +`true` + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### flatJson + +**Signature:** +```typescript +flatJson?: boolean; +``` + +**Details** + +Allow use flat json messages or not + +**Default Value** + +`false` + +### inheritLocale + +**Signature:** +```typescript +inheritLocale?: boolean; +``` + +**Details** + +Whether inheritance the root level locale to the component localization locale. + +If `false`, regardless of the root level locale, localize for each component locale. + +**Default Value** + +`true` + +**See Also** +- [Local Scope](../guide/essentials/scope#local-scope-2) + +### locale + +**Signature:** +```typescript +locale?: Locale; +``` + +**Details** + +The locale of localization. + +If the locale contains a territory and a dialect, this locale contains an implicit fallback. + +**Default Value** + +`'en-US'` + +**See Also** +- [Scope and Locale Changing](../guide/essentials/scope) + +### message + +### messageCompiler + +**Signature:** +```typescript +messageCompiler?: MessageCompiler; +``` + +**Details** + +A compiler for custom message format. + +If not specified, the vue-i18n default message compiler will be used. + +You will need to implement your own message compiler that returns Message Functions + +:::tip +:new: v9.3+ +::: + +:::warning +The Custom Message Format is an experimental feature. It may receive breaking changes or be removed in the future. +::: + +**Default Value** + +`undefined` + +**See Also** +- [Custom Message Format](../guide/advanced/format) + +**Examples** + +Here is an example of how to custom message compiler with `intl-messageformat` +```js +import { createI18n } from 'vue-i18n' +import IntlMessageFormat from 'intl-messageformat' + +function messageCompiler(message, { locale, key, onError }) { + if (typeof message === 'string') { + // You can tune your message compiler performance more with your cache strategy or also memoization at here + const formatter = new IntlMessageFormat(message, locale) + return ctx => formatter.format(ctx.values) + } else { + // If you would like to support it for AST, + // You need to transform locale mesages such as `json`, `yaml`, etc. with the bundle plugin. + onError && onError(new Error('not support for AST')) + return () => key // return default with `key` + } +} + +// call with I18n option +const i18n = createI18n({ + legacy: false, + locale: 'ja', + messageCompiler, // set your message compiler + messages: { + en: { + hello: 'hello world!', + greeting: 'hi, {name}!', + // ICU Message format + photo: `You have {numPhotos, plural, + =0 {no photos.} + =1 {one photo.} + other {# photos.} + }` + }, + } +}) + +// the below your something to do ... +// ... +``` + + + + +### messageResolver + +**Signature:** +```typescript +messageResolver?: MessageResolver; +``` + +**Details** + +A message resolver to resolve [`messages`](composition#messages). + +If not specified, the vue-i18n internal message resolver will be used by default. + +You need to implement a message resolver yourself that supports the following requirements: + +- Resolve the message using the locale message of [`locale`](composition#locale) passed as the first argument of the message resolver, and the path passed as the second argument. + +- If the message could not be resolved, you need to return `null`. + +- If you will be returned `null`, the message resolver will also be called on fallback if [`fallbackLocale`](composition#fallbacklocale-2) is enabled, so the message will need to be resolved as well. + +The message resolver is called indirectly by the following APIs: + +- [`t`](composition#t-key) + +- [`te`](composition#te-key-locale) + +- [`tm`](composition#tm-key) + +- [Translation component](component#translation) + +:::tip +:new: v9.2+ +::: + +:::warning +If you use the message resolver, the [`flatJson`](composition#flatjson) setting will be ignored. That is, you need to resolve the flat JSON by yourself. +::: + +**Default Value** + +`undefined` + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +**Examples** + +Here is an example of how to set it up using your `createI18n`: +```js +import { createI18n } from 'vue-i18n' + +// your message resolver +function messageResolver(obj, path) { + // simple message resolving! + const msg = obj[path] + return msg != null ? msg : null +} + +// call with I18n option +const i18n = createI18n({ + legacy: false, + locale: 'ja', + messageResolver, // set your message resolver + messages: { + en: { ... }, + ja: { ... } + } +}) + +// the below your something to do ... +// ... +``` + + + + +### messages + +### missing + +**Signature:** +```typescript +missing?: MissingHandler; +``` + +**Details** + +A handler for localization missing. + +The handler gets called with the localization target locale, localization path key, the Vue instance and values. + +If missing handler is assigned, and occurred localization missing, it's not warned. + +**Default Value** + +`null` + +### missingWarn + +**Signature:** +```typescript +missingWarn?: boolean | RegExp; +``` + +**Details** + +Whether suppress warnings outputted when localization fails. + +If `false`, suppress localization fail warnings. + +If you use regular expression, you can suppress localization fail warnings that it match with translation key (e.g. `t`). + +**Default Value** + +`true` + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### modifiers + +**Signature:** +```typescript +modifiers?: LinkedModifiers; +``` + +**Details** + +Custom Modifiers for linked messages. + +**See Also** +- [Custom Modifiers](../guide/essentials/syntax#custom-modifiers) + +### number + +### numberFormats + +### pluralRules + +**Signature:** +```typescript +pluralRules?: PluralizationRules; +``` + +**Details** + +A set of rules for word pluralization + +**Default Value** + +`{}` + +**See Also** +- [Custom Pluralization](../guide/essentials/pluralization#custom-pluralization) + +### postTranslation + +**Signature:** +```typescript +postTranslation?: PostTranslationHandler; +``` + +**Details** + +A handler for post processing of translation. + +The handler gets after being called with the `t`. + +This handler is useful if you want to filter on translated text such as space trimming. + +**Default Value** + +`null` + +### warnHtmlMessage + +**Signature:** +```typescript +warnHtmlMessage?: boolean; +``` + +**Details** + +Whether to allow the use locale messages of HTML formatting. + +See the warnHtmlMessage property. + +**Default Value** + +`'off'` + +**See Also** +- [HTML Message](../guide/essentials/syntax#html-message) +- [Change `warnHtmlInMessage` option default value](../guide/migration/breaking#change-warnhtmlinmessage-option-default-value) + +## ComposerResolveLocaleMessageTranslation + +Resolve locale message translation functions + +**Signature:** +```typescript +export interface ComposerResolveLocaleMessageTranslation +``` + +**Details** + +This is the interface for [Composer](composition#composer) + +### (message: MessageFunction<VueMessageType> | VueMessageType): string; + +Resolve locale message translation + +**Signature:** +```typescript +(message: MessageFunction | VueMessageType): string; +``` + +**Details** + +If this is used in a reactive context, it will re-evaluate once the locale changes. + +If [UseI18nScope](general#usei18nscope) `'local'` or Some [UseI18nOptions](composition#usei18noptions) are specified at `useI18n`, it’s translated in preferentially local scope locale messages than global scope locale messages. + +If not, then it’s translated with global scope locale messages. + +**See Also** +- [Scope and Locale Changing](../guide/essentials/scope) + +:::tip +The use-case for `rt` is for programmatic locale messages translation with using `tm`, `v-for`, javascript `for` statement. +::: + +:::warning +`rt` differs from `t` in that it processes the locale message directly, not the key of the locale message. There is no internal fallback with `rt`. You need to understand and use the structure of the locale messge returned by `tm`. +::: + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| message | MessageFunction<VueMessageType> | VueMessageType | A target locale message to be resolved. You will need to specify the locale message returned by `tm`. | + +#### Returns + + Translated message + +### (message: MessageFunction<VueMessageType> | VueMessageType, plural: number, options?: TranslateOptions<Locales>): string; + +Resolve locale message translation for plurals + +**Signature:** +```typescript +(message: MessageFunction | VueMessageType, plural: number, options?: TranslateOptions): string; +``` + +**Details** + +Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-message-message-string) details. + +In this overloaded `rt`, return a pluralized translation message. + +**See Also** +- [Pluralization](../guide/essentials/pluralization) + +:::tip +The use-case for `rt` is for programmatic locale messages translation with using `tm`, `v-for`, javascript `for` statement. +::: + +:::warning +`rt` differs from `t` in that it processes the locale message directly, not the key of the locale message. There is no internal fallback with `rt`. You need to understand and use the structure of the locale messge returned by `tm`. +::: + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| message | MessageFunction<VueMessageType> | VueMessageType | A target locale message to be resolved. You will need to specify the locale message returned by `tm`. | +| plural | number | Which plural string to get. 1 returns the first one. | +| options | TranslateOptions<Locales> | Additional for translation | + +#### Returns + + Translated message + +### (message: MessageFunction<VueMessageType> | VueMessageType, list: unknown[], options?: TranslateOptions<Locales>): string; + +Resolve locale message translation for list interpolations + +**Signature:** +```typescript +(message: MessageFunction | VueMessageType, list: unknown[], options?: TranslateOptions): string; +``` + +**Details** + +Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-message-message-string) details. + +In this overloaded `rt`, return a pluralized translation message. + +**See Also** +- [List interpolation](../guide/essentials/syntax#list-interpolation) + +:::tip +The use-case for `rt` is for programmatic locale messages translation with using `tm`, `v-for`, javascript `for` statement. +::: + +:::warning +`rt` differs from `t` in that it processes the locale message directly, not the key of the locale message. There is no internal fallback with `rt`. You need to understand and use the structure of the locale messge returned by `tm`. +::: + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| message | MessageFunction<VueMessageType> | VueMessageType | A target locale message to be resolved. You will need to specify the locale message returned by `tm`. | +| list | unknown[] | A values of list interpolation. | +| options | TranslateOptions<Locales> | Additional for translation | + +#### Returns + + Translated message + +### (message: MessageFunction<VueMessageType> | VueMessageType, named: NamedValue, options?: TranslateOptions<Locales>): string; + +Resolve locale message translation for named interpolations + +**Signature:** +```typescript +(message: MessageFunction | VueMessageType, named: NamedValue, options?: TranslateOptions): string; +``` + +**Details** + +Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-message-message-string) details. + +In this overloaded `rt`, for each placeholder x, the locale messages should contain a `{x}` token. + +**See Also** +- [Named interpolation](../guide/essentials/syntax#named-interpolation) + +:::tip +The use-case for `rt` is for programmatic locale messages translation with using `tm`, `v-for`, javascript `for` statement. +::: + +:::warning +`rt` differs from `t` in that it processes the locale message directly, not the key of the locale message. There is no internal fallback with `rt`. You need to understand and use the structure of the locale messge returned by `tm`. +::: + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| message | MessageFunction<VueMessageType> | VueMessageType | A target locale message to be resolved. You will need to specify the locale message returned by `tm`. | +| named | NamedValue | A values of named interpolation. | +| options | TranslateOptions<Locales> | Additional for translation | + +#### Returns + + Translated message + +## ComposerTranslation + +Locale message translation functions + +**Signature:** +```typescript +export interface ComposerTranslation = {}, Locales = 'en-US', DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, C = IsEmptyObject extends false ? JsonPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, M = IsEmptyObject extends false ? TranslationsPaths : never, ResourceKeys extends C | M = IsNever extends false ? IsNever extends false ? C | M : C : IsNever extends false ? M : never> +``` + +**Details** + +This is the interface for [Composer](composition#composer) + +### (key: Key | ResourceKeys | number): string; + +Locale message translation + +**Signature:** +```typescript +(key: Key | ResourceKeys | number): string; +``` + +**Details** + +If this is used in a reactive context, it will re-evaluate once the locale changes. + +If [UseI18nScope](general#usei18nscope) `'local'` or Some [UseI18nOptions](composition#usei18noptions) are specified at `useI18n`, it’s translated in preferentially local scope locale messages than global scope locale messages. + +If not, then it’s translated with global scope locale messages. + +**See Also** +- [Scope and Locale Changing](../guide/essentials/scope) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | number | A target locale message key | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys | number, named: NamedValue): string; + +Locale message translation for named interpolations + +**Signature:** +```typescript +(key: Key | ResourceKeys | number, named: NamedValue): string; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. + +In this overloaded `t`, for each placeholder x, the locale messages should contain a `{x}` token. + +You can also suppress the warning, when the translation missing according to the options. + +**See Also** +- [Named interpolation](../guide/essentials/syntax#named-interpolation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | number | A target locale message key | +| named | NamedValue | A values of named interpolation | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys | number, named: NamedValue, plural: number): string; + +Locale message translation for named interpolations and plurals + +**Signature:** +```typescript +(key: Key | ResourceKeys | number, named: NamedValue, plural: number): string; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. + +In this overloaded `t`, for each placeholder x, the locale messages should contain a `{x}` token, and return a pluralized translation message. + +**See Also** +- [Pluralization](../guide/essentials/pluralization) +- [Named interpolation](../guide/essentials/syntax#named-interpolation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | number | A target locale message key | +| named | NamedValue | A values of named interpolation | +| plural | number | Which plural string to get. 1 returns the first one. | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys | number, named: NamedValue, defaultMsg: string): string; + +Locale message translation for named interpolations and plurals + +**Signature:** +```typescript +(key: Key | ResourceKeys | number, named: NamedValue, defaultMsg: string): string; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. + +In this overloaded `t`, for each placeholder x, the locale messages should contain a `{x}` token, and if no translation was found, return a default message. + +**See Also** +- [Named interpolation](../guide/essentials/syntax#named-interpolation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | number | A target locale message key | +| named | NamedValue | A values of named interpolation | +| defaultMsg | string | A default message to return if no translation was found | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys | number, named: NamedValue, options: TranslateOptions<Locales>): string; + +Locale message translation for named interpolations + +**Signature:** +```typescript +(key: Key | ResourceKeys | number, named: NamedValue, options: TranslateOptions): string; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. + +In this overloaded `t`, for each placeholder x, the locale messages should contain a `{x}` token. + +You can also suppress the warning, when the translation missing according to the options. + +About details of options, see the . + +**See Also** +- [Named interpolation](../guide/essentials/syntax#named-interpolation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | number | A target locale message key | +| named | NamedValue | A values of named interpolation | +| options | TranslateOptions<Locales> | Additional for translation | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys | number, plural: number): string; + +Locale message translation for plurals + +**Signature:** +```typescript +(key: Key | ResourceKeys | number, plural: number): string; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. + +In this overloaded `t`, return a pluralized translation message. + +You can also suppress the warning, when the translation missing according to the options. + +**See Also** +- [Pluralization](../guide/essentials/pluralization) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | number | A target locale message key | +| plural | number | Which plural string to get. 1 returns the first one. | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys | number, plural: number, options: TranslateOptions<Locales>): string; + +Locale message translation for plurals + +**Signature:** +```typescript +(key: Key | ResourceKeys | number, plural: number, options: TranslateOptions): string; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. + +In this overloaded `t`, return a pluralized translation message. + +You can also suppress the warning, when the translation missing according to the options. + +About details of options, see the . + +**See Also** +- [Pluralization](../guide/essentials/pluralization) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | number | A target locale message key | +| plural | number | Which plural string to get. 1 returns the first one. | +| options | TranslateOptions<Locales> | Additional for translation | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys | number, defaultMsg: string): string; + +Locale message translation for missing default message + +**Signature:** +```typescript +(key: Key | ResourceKeys | number, defaultMsg: string): string; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. + +In this overloaded `t`, if no translation was found, return a default message. + +You can also suppress the warning, when the translation missing according to the options. + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | number | A target locale message key | +| defaultMsg | string | A default message to return if no translation was found | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys | number, defaultMsg: string, options: TranslateOptions<Locales>): string; + +Locale message translation for missing default message + +**Signature:** +```typescript +(key: Key | ResourceKeys | number, defaultMsg: string, options: TranslateOptions): string; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. + +In this overloaded `t`, if no translation was found, return a default message. + +You can also suppress the warning, when the translation missing according to the options. + +About details of options, see the . + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | number | A target locale message key | +| defaultMsg | string | A default message to return if no translation was found | +| options | TranslateOptions<Locales> | Additional for translation | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys | number, list: unknown[]): string; + +Locale message translation for list interpolations + +**Signature:** +```typescript +(key: Key | ResourceKeys | number, list: unknown[]): string; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. + +In this overloaded `t`, the locale messages should contain a `{0}`, `{1}`, … for each placeholder in the list. + +You can also suppress the warning, when the translation missing according to the options. + +**See Also** +- [List interpolation](../guide/essentials/syntax#list-interpolation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | number | A target locale message key | +| list | unknown[] | A values of list interpolation | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys | number, list: unknown[], plural: number): string; + +Locale message translation for list interpolations and plurals + +**Signature:** +```typescript +(key: Key | ResourceKeys | number, list: unknown[], plural: number): string; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. + +In this overloaded `t`, the locale messages should contain a `{0}`, `{1}`, … for each placeholder in the list, and return a pluralized translation message. + +**See Also** +- [Pluralization](../guide/essentials/pluralization) +- [List interpolation](../guide/essentials/syntax#list-interpolation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | number | A target locale message key | +| list | unknown[] | A values of list interpolation | +| plural | number | Which plural string to get. 1 returns the first one. | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys | number, list: unknown[], defaultMsg: string): string; + +Locale message translation for list interpolations and missing default message + +**Signature:** +```typescript +(key: Key | ResourceKeys | number, list: unknown[], defaultMsg: string): string; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. + +In this overloaded `t`, the locale messages should contain a `{0}`, `{1}`, … for each placeholder in the list, and if no translation was found, return a default message. + +**See Also** +- [List interpolation](../guide/essentials/syntax#list-interpolation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | number | A target locale message key | +| list | unknown[] | A values of list interpolation | +| defaultMsg | string | A default message to return if no translation was found | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys | number, list: unknown[], options: TranslateOptions<Locales>): string; + +Locale message translation for list interpolations + +**Signature:** +```typescript +(key: Key | ResourceKeys | number, list: unknown[], options: TranslateOptions): string; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. + +In this overloaded `t`, the locale messages should contain a `{0}`, `{1}`, … for each placeholder in the list. + +You can also suppress the warning, when the translation missing according to the options. + +About details of options, see the . + +**See Also** +- [List interpolation](../guide/essentials/syntax#list-interpolation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | number | A target locale message key | +| list | unknown[] | A values of list interpolation | +| options | TranslateOptions<Locales> | Additional for translation | + +#### Returns + + Translated message + +## MissingHandler + +**Signature:** +```typescript +export type MissingHandler = (locale: Locale, key: Path, instance?: ComponentInternalInstance, type?: string) => string | void; +``` + +## useI18n + +Use Composition API for Vue I18n + +**Signature:** +```typescript +export declare function useI18n, LocaleParams> = UseI18nOptions, LocaleParams>>(options?: Options): Composer, NonNullable, NonNullable, NonNullable>; +``` + +### Type Parameters + +| Parameter | Description | +| --- | --- | +| Schema | The i18n resources (messages, datetimeFormats, numberFormats) schema, default | +| Locales | The locales of i18n resource schema, default `en-US` | + +**Details** + +This function is mainly used by `setup`. + +If options are specified, Composer instance is created for each component and you can be localized on the component. + +If options are not specified, you can be localized using the global Composer. + +### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| options | Options | An options, see [UseI18nOptions](composition#usei18noptions) | + +### Returns + + [Composer](composition#composer) instance + +**Examples** + +case: Component resource base localization +```html + + + +``` + + + + +## UseI18nOptions + +I18n Options for `useI18n` + +**Signature:** +```typescript +export type UseI18nOptions = ComposerOptions> = ComposerAdditionalOptions & Options; +``` + +**Details** + +`UseI18nOptions` is inherited [ComposerAdditionalOptions](composition#composeradditionaloptions) and [ComposerOptions](composition#composeroptions), so you can specify these options. + +**See Also** +- [useI18n](composition#usei18n) + +## VueMessageType + +**Signature:** +```typescript +export type VueMessageType = string | ResourceNode | VNode; +``` + diff --git a/docs/api/directive.md b/docs/api/directive.md new file mode 100644 index 000000000..77a9650a3 --- /dev/null +++ b/docs/api/directive.md @@ -0,0 +1,52 @@ +# Directives + +## TranslationDirective + +Translation Directive (`v-t`) + +**Signature:** +```typescript +export type TranslationDirective = ObjectDirective; +``` + +:::danger DEPRECATED +will be removed at vue-i18n v12 +::: + +**Details** + +Update the element `textContent` that localized with locale messages. + +You can use string syntax or object syntax. + +String syntax can be specified as a keypath of locale messages. + +If you can be used object syntax, you need to specify as the object key the following params +``` +- path: required, key of locale messages +- locale: optional, locale +- args: optional, for list or named formatting +``` + + + +**Examples** + + +```html + +

+ + +

+ + +

+ + +

+``` + + + + diff --git a/docs/api/general.md b/docs/api/general.md new file mode 100644 index 000000000..bcf35d0d4 --- /dev/null +++ b/docs/api/general.md @@ -0,0 +1,1299 @@ +# 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): (typeof options)['legacy'] extends true ? I18n : (typeof options)['legacy'] extends false ? I18n : I18n; +``` + +### Type Parameters + +| Parameter | Description | +| --- | --- | +| Schema | The i18n resources (messages, datetimeFormats, numberFormats) schema, default | +| Locales | The locales of i18n resource schema, default `en-US` | +| Legacy | Whether legacy mode is enabled or disabled, default `true` | + +**Details** + +If you use Legacy API mode, you need to specify [VueI18nOptions](legacy#vuei18noptions) and `legacy: true` option. + +If you use composition API mode, you need to specify [ComposerOptions](composition#composeroptions). + +**See Also** +- [Getting Started](../guide/essentials/started) +- [Composition API](../guide/advanced/composition) + +### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| options | Options | An options, see the [I18nOptions](general#i18noptions) | + +### Returns + + [I18n](general#i18n) instance + +**Examples** + +**Example 1:** + +case: for Legacy API +```js +import { createApp } from 'vue' +import { createI18n } from 'vue-i18n' + +// call with I18n option +const i18n = createI18n({ + locale: 'ja', + messages: { + en: { ... }, + ja: { ... } + } +}) + +const App = { + // ... +} + +const app = createApp(App) + +// install! +app.use(i18n) +app.mount('#app') +``` + + + +**Example 2:** + +case: for composition API +```js +import { createApp } from 'vue' +import { createI18n, useI18n } from 'vue-i18n' + +// call with I18n option +const i18n = createI18n({ + legacy: false, // you must specify 'legacy: false' option + 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 proxy-like property for `Composer#availableLocales`. About details, see the [Composer#availableLocales](composition#availablelocales) + +### fallbackLocale + +Fallback locale + +**Signature:** +```typescript +fallbackLocale: FallbackLocale; +``` + +**Details** + +This property is proxy-like property for `Composer#fallbackLocale`. About details, see the [Composer#fallbackLocale](composition#fallbacklocale) + +### locale + +Locale + +**Signature:** +```typescript +locale: Locale; +``` + +**Details** + +This property is proxy-like property for `Composer#locale`. About details, see the [Composer#locale](composition#locale) + +## I18n + +I18n instance + +**Signature:** +```typescript +export interface I18n = {}, DateTimeFormats extends Record = {}, NumberFormats extends Record = {}, OptionLocale = Locale, Legacy = boolean> +``` + +**Details** + +The instance required for installation as the Vue plugin + +### global + +The property accessible to the global Composer instance or VueI18n instance + +**Signature:** +```typescript +readonly global: Legacy extends true ? VueI18n : Legacy extends false ? Composer : unknown; +``` + +**Details** + +If the [I18n#mode](general#mode) is `'legacy'`, then you can access to a global [VueI18n](legacy#vuei18n) instance, else then [I18n#mode](general#mode) is `'composition' `, you can access to the global [Composer](composition#composer) instance. + +An instance of this property is **global scope***. + +### mode + +Vue I18n API mode + +**Signature:** +```typescript +readonly mode: I18nMode; +``` + +:::danger DEPRECATED +will be removed at vue-i18n v12 +::: + +**Details** + +If you specified `legacy: true` option in `createI18n`, return `legacy`, else `composition` + +**Default Value** + +`'legacy'` + +### 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** + +Specific options for + +### 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. + +**Default Value** + +`true` + +**See Also** +- [Implicit with injected properties and functions](../guide/advanced/composition#implicit-with-injected-properties-and-functions) +- [ComponentCustomProperties](injection#componentcustomproperties) + +### legacy + +Whether vue-i18n Legacy API mode use on your Vue App + +**Signature:** +```typescript +legacy?: boolean; +``` + +:::danger DEPRECATED +will be removed at vue-i18n v12 +::: + +**Details** + +The default is to use the Legacy API mode. If you want to use the Composition API mode, you need to set it to `false`. + +**Default Value** + +`true` + +**See Also** +- [Composition API](../guide/advanced/composition) + +## I18nInjectionKey + +Injection key for + +**Signature:** +```typescript +I18nInjectionKey: InjectionKey | string +``` + +**Details** + +The global injection key for I18n instances with `useI18n`. this injection key is used in Web Components. Specify the i18n instance created by together with `provide` function. + +## I18nMode + +Vue I18n API mode + +**Signature:** +```typescript +export type I18nMode = 'legacy' | 'composition'; +``` + +:::danger DEPRECATED +will be removed at vue-i18n v12 +::: + +**See Also** +- [I18n#mode](general#mode) + +## I18nOptions + +I18n Options for `createI18n` + +**Signature:** +```typescript +export type I18nOptions | VueI18nOptions = ComposerOptions | VueI18nOptions> = I18nAdditionalOptions & Options; +``` + +**Details** + +`I18nOptions` is inherited [I18nAdditionalOptions](general#i18nadditionaloptions), [ComposerOptions](composition#composeroptions) and [VueI18nOptions](legacy#vuei18noptions), so you can specify these 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. + +**Default Value** + +`true` + +## I18nScope + +I18n Scope + +**Signature:** +```typescript +export type I18nScope = 'local' | 'parent' | 'global'; +``` + +**See Also** +- [ComposerAdditionalOptions#useScope](composition#usescope) +- [useI18n](composition#usei18n) + +## 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 implemenation + +**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, it returns the value as specified in the `fallbackLocale` props, and is processed with the fallback inside intlify. + +### 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 + +## 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, optoins) + +Overloaded `linked` + +**Signature:** +```typescript +linked(key: Path, optoins?: LinkedOptions): MessageType; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Path | A message key | +| optoins | 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 + diff --git a/docs/api/legacy.md b/docs/api/legacy.md new file mode 100644 index 000000000..acd623dd3 --- /dev/null +++ b/docs/api/legacy.md @@ -0,0 +1,1701 @@ +# Legacy API + +## Choice + +**Signature:** +```typescript +export type Choice = number; +``` + +:::danger DEPRECATED +will be removed at vue-i18n v12 +::: + +## DateTimeFormatResult + +**Signature:** +```typescript +export type DateTimeFormatResult = string; +``` + +:::danger DEPRECATED +will be removed at vue-i18n v12 +::: + +## LocaleMessageObject + +**Signature:** +```typescript +export type LocaleMessageObject = LocaleMessageDictionary; +``` + +:::danger DEPRECATED +will be removed at vue-i18n v12 +::: + +## NumberFormatResult + +**Signature:** +```typescript +export type NumberFormatResult = string; +``` + +:::danger DEPRECATED +will be removed at vue-i18n v12 +::: + +## PluralizationRulesMap + +**Signature:** +```typescript +export type PluralizationRulesMap = { + [locale: string]: PluralizationRule; +}; +``` + +:::danger DEPRECATED +will be removed at vue-i18n v12 +::: + +## TranslateResult + +**Signature:** +```typescript +export type TranslateResult = string; +``` + +:::danger DEPRECATED +will be removed at vue-i18n v12 +::: + +## VueI18n + +VueI18n legacy interfaces + +**Signature:** +```typescript +export interface VueI18n = {}, DateTimeFormats extends Record = {}, NumberFormats extends Record = {}, OptionLocale = Locale, ResourceLocales = PickupLocales> | PickupLocales> | PickupLocales>, Locales = Locale extends GeneratedLocale ? GeneratedLocale : OptionLocale extends string ? [ResourceLocales] extends [never] ? Locale : ResourceLocales : OptionLocale | ResourceLocales, Composition extends Composer = Composer> +``` + +:::danger DEPRECATED +will be removed at vue-i18n v12 +::: + +**Details** + +This interface is compatible with interface of `VueI18n` class (offered with Vue I18n v8.x). + +### availableLocales + +**Signature:** +```typescript +readonly availableLocales: Composition['availableLocales']; +``` + +**Details** + +The list of available locales in `messages` in lexical order. + +### d + +Datetime formatting + +**Signature:** +```typescript +d: VueI18nDateTimeFormatting>; +``` + +**Details** + +About details functions, See the [VueI18nDateTimeFormatting](legacy#vuei18ndatetimeformatting) + +### datetimeFormats + +**Signature:** +```typescript +readonly datetimeFormats: { + [K in keyof DateTimeFormats]: DateTimeFormats[K]; + }; +``` + +**Details** + +The datetime formats of localization. + +**See Also** +- [Datetime Formatting](../guide/essentials/datetime) + +### escapeParameterHtml + +**Signature:** +```typescript +escapeParameterHtml: Composition['escapeParameter']; +``` + +**Details** + +Whether interpolation parameters are escaped before the message is translated. + +**See Also** +- [HTML Message](../guide/essentials/syntax#html-message) + +### fallbackLocale + +**Signature:** +```typescript +fallbackLocale: FallbackLocales; +``` + +**Details** + +The current fallback locales this VueI18n instance is using. + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### formatFallbackMessages + +**Signature:** +```typescript +formatFallbackMessages: Composition['fallbackFormat']; +``` + +**Details** + +Whether suppress warnings when falling back to either `fallbackLocale` or root. + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### getDateTimeFormat + +Get datetime format + +**Signature:** +```typescript +getDateTimeFormat: Composition['getDateTimeFormat']; +``` + +**Details** + +get datetime format from VueI18n instance [datetimeFormats](legacy#datetimeformats). + +### getLocaleMessage + +Get locale message + +**Signature:** +```typescript +getLocaleMessage: Composition['getLocaleMessage']; +``` + +**Details** + +get locale message from VueI18n instance [messages](legacy#messages). + +### getNumberFormat + +Get number format + +**Signature:** +```typescript +getNumberFormat: Composition['getNumberFormat']; +``` + +**Details** + +get number format from VueI18n instance [numberFormats](legacy#numberFormats). + +### id + +**Signature:** +```typescript +id: number; +``` + +**Details** + +Instance ID. + +### locale + +**Signature:** +```typescript +locale: Locales; +``` + +**Details** + +The current locale this VueI18n instance is using. + +If the locale contains a territory and a dialect, this locale contains an implicit fallback. + +**See Also** +- [Scope and Locale Changing](../guide/essentials/scope) + +### mergeDateTimeFormat + +Merge datetime format + +**Signature:** +```typescript +mergeDateTimeFormat: Composition['mergeDateTimeFormat']; +``` + +**Details** + +Merge datetime format to VueI18n instance [datetimeFormats](legacy#datetimeformats). + +### mergeLocaleMessage + +Merge locale message + +**Signature:** +```typescript +mergeLocaleMessage: Composition['mergeLocaleMessage']; +``` + +**Details** + +Merge locale message to VueI18n instance [messages](legacy#messages). + +### mergeNumberFormat + +Merge number format + +**Signature:** +```typescript +mergeNumberFormat: Composition['mergeNumberFormat']; +``` + +**Details** + +Merge number format to VueI18n instance [numberFormats](legacy#numberFormats). + +### messages + +**Signature:** +```typescript +readonly messages: { + [K in keyof Messages]: Messages[K]; + }; +``` + +**Details** + +The locale messages of localization. + +**See Also** +- [Getting Started](../guide/essentials/started) + +### missing + +**Signature:** +```typescript +missing: MissingHandler | null; +``` + +**Details** + +A handler for localization missing. + +### modifiers + +**Signature:** +```typescript +readonly modifiers: Composition['modifiers']; +``` + +**Details** + +Custom Modifiers for linked messages. + +**See Also** +- [Custom Modifiers](../guide/essentials/syntax#custom-modifiers) + +### n + +Number Formatting + +**Signature:** +```typescript +n: VueI18nNumberFormatting>; +``` + +**Details** + +About details functions, See the [VueI18nNumberFormatting](legacy#vuei18nnumberformatting) + +### numberFormats + +**Signature:** +```typescript +readonly numberFormats: { + [K in keyof NumberFormats]: NumberFormats[K]; + }; +``` + +**Details** + +The number formats of localization. + +**See Also** +- [Number Formatting](../guide/essentials/number) + +### pluralizationRules + +A set of rules for word pluralization + +**Signature:** +```typescript +pluralizationRules: Composition['pluralRules']; +``` + +**See Also** +- [Custom Pluralization](../guide/essentials/pluralization#custom-pluralization) + +### postTranslation + +**Signature:** +```typescript +postTranslation: PostTranslationHandler | null; +``` + +**Details** + +A handler for post processing of translation. + +### rt + +Resolve locale message translation + +**Signature:** +```typescript +rt: VueI18nResolveLocaleMessageTranslation; +``` + +**Details** + +About details functions, See the [VueI18nResolveLocaleMessageTranslation](legacy#vuei18nresolvelocalemessagetranslation) + +### setDateTimeFormat + +Set datetime format + +**Signature:** +```typescript +setDateTimeFormat: Composition['setDateTimeFormat']; +``` + +**Details** + +Set datetime format to VueI18n instance [datetimeFormats](legacy#datetimeformats). + +### setLocaleMessage + +Set locale message + +**Signature:** +```typescript +setLocaleMessage: Composition['setLocaleMessage']; +``` + +**Details** + +Set locale message to VueI18n instance [messages](legacy#messages). + +### setNumberFormat + +Set number format + +**Signature:** +```typescript +setNumberFormat: Composition['setNumberFormat']; +``` + +**Details** + +Set number format to VueI18n instance [numberFormats](legacy#numberFormats). + +### silentFallbackWarn + +**Signature:** +```typescript +silentFallbackWarn: Composition['fallbackWarn']; +``` + +**Details** + +Whether suppress fallback warnings when localization fails. + +### silentTranslationWarn + +**Signature:** +```typescript +silentTranslationWarn: Composition['missingWarn']; +``` + +**Details** + +Whether suppress warnings outputted when localization fails. + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### sync + +**Signature:** +```typescript +sync: Composition['inheritLocale']; +``` + +**Details** + +Whether synchronize the root level locale to the component localization locale. + +**See Also** +- [Local Scope](../guide/essentials/scope#local-scope-2) + +### t + +Locale message translation + +**Signature:** +```typescript +t: VueI18nTranslation>; +``` + +**Details** + +About details functions, See the [VueI18nTranslation](legacy#vuei18ntranslation) + +### tm + +Locale messages getter + +**Signature:** +```typescript +tm: Composition['tm']; +``` + +**Details** + +If [i18n component options](injection#i18n) is specified, it’s get in preferentially local scope locale messages than global scope locale messages. + +If [i18n component options](injection#i18n) isn't specified, it’s get with global scope locale messages. + +Based on the current `locale`, locale messages will be returned from Composer instance messages. + +If you change the `locale`, the locale messages returned will also correspond to the locale. + +If there are no locale messages for the given `key` in the composer instance messages, they will be returned with [fallbacking](../guide/essentials/fallback). + +:::warning +You need to use `rt` for the locale message returned by `tm`. see the [rt](legacy#rt-message) details. +::: + +**Examples** + +template: +```html +
+ +
+``` + + +```js +import { createI18n } from 'vue-i18n' + +const i18n = createI18n({ + messages: { + en: { + contents: [ + { + title: 'Title1', + // ... + paragraphs: [ + // ... + ] + } + ] + } + } + // ... +}) +``` + + + + +### warnHtmlInMessage + +**Signature:** +```typescript +warnHtmlInMessage: WarnHtmlInMessageLevel; +``` + +**Details** + +Whether to allow the use locale messages of HTML formatting. + +If you set `warn` or` error`, will check the locale messages on the VueI18n instance. + +If you are specified `warn`, a warning will be output at console. + +If you are specified `error` will occurred an Error. + +**See Also** +- [HTML Message](../guide/essentials/syntax#html-message) +- [Change `warnHtmlInMessage` option default value](../guide/migration/breaking#change-warnhtmlinmessage-option-default-value) + +### te(key, locale) + +Translation locale message exist + +**Signature:** +```typescript +te = PickupKeys>(key: Str | Key, locale?: Locales): boolean; +``` + +**Details** + +whether do exist locale message on VueI18n instance [messages](legacy#messages). + +If you specified `locale`, check the locale messages of `locale`. + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Str | Key | A target locale message key | +| locale | Locales | A target locale | + +#### Returns + + If found locale message, `true`, else `false` + +## VueI18nDateTimeFormatting + +Datetime formatting functions for VueI18n legacy interfaces + +**Signature:** +```typescript +export interface VueI18nDateTimeFormatting = {}, Locales = 'en-US', DefinedDateTimeFormat extends RemovedIndexResources = RemovedIndexResources, C = IsEmptyObject extends false ? PickupFormatPathKeys<{ + [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K]; +}> : never, M = IsEmptyObject extends false ? PickupFormatKeys : never, ResourceKeys extends C | M = IsNever extends false ? IsNever extends false ? C | M : C : IsNever extends false ? M : never> +``` + +:::danger DEPRECATED +will be removed at vue-i18n v12 +::: + +**Details** + +This is the interface for [VueI18n](legacy#vuei18n) + +### (value: number | Date): DateTimeFormatResult; + +Datetime formatting + +**Signature:** +```typescript +(value: number | Date): DateTimeFormatResult; +``` + +**Details** + +If this is used in a reactive context, it will re-evaluate once the locale changes. + +If [i18n component options](injection#i18n) is specified, it’s formatted in preferentially local scope datetime formats than global scope locale messages. + +If [i18n component options](injection#i18n) isn't specified, it’s formatted with global scope datetime formats. + +**See Also** +- [Datetime formatting](../guide/essentials/datetime) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | Date | A value, timestamp number or `Date` instance | + +#### Returns + + Formatted value + +### (value: Value, key: Key | ResourceKeys): DateTimeFormatResult; + +Datetime formatting + +**Signature:** +```typescript +(value: Value, key: Key | ResourceKeys): DateTimeFormatResult; +``` + +**Details** + +Overloaded `d`. About details, see the [call signature](legacy#value-number-date-datetimeformatresult) details. + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | Value | A value, timestamp number or `Date` instance | +| key | Key | ResourceKeys | A key of datetime formats | + +#### Returns + + Formatted value + +### (value: Value, key: Key | ResourceKeys, locale: Locales): DateTimeFormatResult; + +Datetime formatting + +**Signature:** +```typescript +(value: Value, key: Key | ResourceKeys, locale: Locales): DateTimeFormatResult; +``` + +**Details** + +Overloaded `d`. About details, see the [call signature](legacy#value-number-date-datetimeformatresult) details. + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | Value | A value, timestamp number or `Date` instance | +| key | Key | ResourceKeys | A key of datetime formats | +| locale | Locales | A locale, it will be used over than global scope or local scope. | + +#### Returns + + Formatted value + +### (value: number | Date, args: { [key: string]: string | boolean | number; }): DateTimeFormatResult; + +Datetime formatting + +**Signature:** +```typescript +(value: number | Date, args: { + [key: string]: string | boolean | number; + }): DateTimeFormatResult; +``` + +**Details** + +Overloaded `d`. About details, see the [call signature](legacy#value-number-date-datetimeformatresult) details. + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | Date | A value, timestamp number or `Date` instance | +| args | { [key: string]: string | boolean | number; } | An argument values | + +#### Returns + + Formatted value + +## VueI18nNumberFormatting + +Number formatting functions for VueI18n legacy interfaces + +**Signature:** +```typescript +export interface VueI18nNumberFormatting = {}, Locales = 'en-US', DefinedNumberFormat extends RemovedIndexResources = RemovedIndexResources, C = IsEmptyObject extends false ? PickupFormatPathKeys<{ + [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K]; +}> : never, M = IsEmptyObject extends false ? PickupFormatKeys : never, ResourceKeys extends C | M = IsNever extends false ? IsNever extends false ? C | M : C : IsNever extends false ? M : never> +``` + +:::danger DEPRECATED +will be removed at vue-i18n v12 +::: + +**Details** + +This is the interface for [VueI18n](legacy#vuei18n) + +### (value: number): NumberFormatResult; + +Number formatting + +**Signature:** +```typescript +(value: number): NumberFormatResult; +``` + +**Details** + +If this is used in a reactive context, it will re-evaluate once the locale changes. + +If [i18n component options](injection#i18n) is specified, it’s formatted in preferentially local scope number formats than global scope locale messages. + +If [i18n component options](injection#i18n) isn't specified, it’s formatted with global scope number formats. + +**See Also** +- [Number formatting](../guide/essentials/number) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | A number value | + +#### Returns + + Formatted value + +### (value: number, key: Key | ResourceKeys): NumberFormatResult; + +Number formatting + +**Signature:** +```typescript +(value: number, key: Key | ResourceKeys): NumberFormatResult; +``` + +**Details** + +Overloaded `n`. About details, see the [call signature](legacy#value-number-numberformatresult) details. + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | A number value | +| key | Key | ResourceKeys | A key of number formats | + +#### Returns + + Formatted value + +### (value: number, key: Key | ResourceKeys, locale: Locales): NumberFormatResult; + +Number formatting + +**Signature:** +```typescript +(value: number, key: Key | ResourceKeys, locale: Locales): NumberFormatResult; +``` + +**Details** + +Overloaded `n`. About details, see the [call signature](legacy#value-number-numberformatresult) details. + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | A number value | +| key | Key | ResourceKeys | A key of number formats | +| locale | Locales | A locale, it will be used over than global scope or local scope. | + +#### Returns + + Formatted value + +### (value: number, args: { [key: string]: string | boolean | number; }): NumberFormatResult; + +Number formatting + +**Signature:** +```typescript +(value: number, args: { + [key: string]: string | boolean | number; + }): NumberFormatResult; +``` + +**Details** + +Overloaded `n`. About details, see the [call signature](legacy#value-number-numberformatresult) details. + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | A number value | +| args | { [key: string]: string | boolean | number; } | An argument values | + +#### Returns + + Formatted value + +## VueI18nOptions + +VueI18n Options + +**Signature:** +```typescript +export interface VueI18nOptions = ComposerOptions> +``` + +:::danger DEPRECATED +will be removed at vue-i18n v12 +::: + +**Details** + +This option is compatible with `VueI18n` class constructor options (offered with Vue I18n v8.x) + +### availableLocales + +**Signature:** +```typescript +availableLocales?: Locale[]; +``` + +**Details** + +The list of available locales in messages in lexical order. + +**Default Value** + +`[]` + +### datetime + +### datetimeFormats + +### escapeParameterHtml + +**Signature:** +```typescript +escapeParameterHtml?: Options['escapeParameter']; +``` + +**Details** + +If `escapeParameterHtml` is configured as true then interpolation parameters are escaped before the message is translated. + +This is useful when translation output is used in `v-html` and the translation resource contains html markup (e.g. around a user provided value). + +This usage pattern mostly occurs when passing precomputed text strings into UI components. + +The escape process involves replacing the following symbols with their respective HTML character entities: `<`, `>`, `"`, `'`. + +Setting `escapeParameterHtml` as true should not break existing functionality but provides a safeguard against a subtle type of XSS attack vectors. + +**Default Value** + +`false` + +**See Also** +- [HTML Message](../guide/essentials/syntax#html-message) + +### fallbackLocale + +**Signature:** +```typescript +fallbackLocale?: Options['fallbackLocale']; +``` + +**Details** + +The locale of fallback localization. + +For more complex fallback definitions see fallback. + +**Default Value** + +The default `'en-US'` for the `locale` if it's not specified, or it's `locale` value + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### fallbackRoot + +**Signature:** +```typescript +fallbackRoot?: Options['fallbackRoot']; +``` + +**Details** + +In the component localization, whether to fall back to root level (global scope) localization when localization fails. + +If `false`, it's not fallback to root. + +**Default Value** + +`true` + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### flatJson + +**Signature:** +```typescript +flatJson?: Options['flatJson']; +``` + +**Details** + +Allow use flat json messages or not + +**Default Value** + +`false` + +### formatFallbackMessages + +**Signature:** +```typescript +formatFallbackMessages?: Options['fallbackFormat']; +``` + +**Details** + +Whether suppress warnings when falling back to either `fallbackLocale` or root. + +**Default Value** + +`false` + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### locale + +**Signature:** +```typescript +locale?: Options['locale']; +``` + +**Details** + +The locale of localization. + +If the locale contains a territory and a dialect, this locale contains an implicit fallback. + +**Default Value** + +`'en-US'` + +**See Also** +- [Scope and Locale Changing](../guide/essentials/scope) + +### message + +### messageResolver + +**Signature:** +```typescript +messageResolver?: MessageResolver; +``` + +**Details** + +A message resolver to resolve [`messages`](legacy#messages). + +If not specified, the vue-i18n internal message resolver will be used by default. + +You need to implement a message resolver yourself that supports the following requirements: + +- Resolve the message using the locale message of [`locale`](legacy#locale) passed as the first argument of the message resolver, and the path passed as the second argument. + +- If the message could not be resolved, you need to return `null`. + +- If you will be returned `null`, the message resolver will also be called on fallback if [`fallbackLocale`](legacy#fallbacklocale-2) is enabled, so the message will need to be resolved as well. + +The message resolver is called indirectly by the following APIs: + +- [`t`](legacy#t-key) + +- [`te`](legacy#te-key-locale) + +- [`tm`](legacy#tm-key) + +- [Translation component](component#translation) + +:::tip +:new: v9.2+ +::: + +:::warning +If you use the message resolver, the [`flatJson`](legacy#flatjson) setting will be ignored. That is, you need to resolve the flat JSON by yourself. +::: + +**Default Value** + +`undefined` + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +**Examples** + +Here is an example of how to set it up using your `createI18n`: +```js +import { createI18n } from 'vue-i18n' + +// your message resolver +function messageResolver(obj, path) { + // simple message resolving! + const msg = obj[path] + return msg != null ? msg : null +} + +// call with I18n option +const i18n = createI18n({ + locale: 'ja', + messageResolver, // set your message resolver + messages: { + en: { ... }, + ja: { ... } + } +}) + +// the below your something to do ... +// ... +``` + + + + +### messages + +### missing + +**Signature:** +```typescript +missing?: Options['missing']; +``` + +**Details** + +A handler for localization missing. + +The handler gets called with the localization target locale, localization path key, the Vue instance and values. + +If missing handler is assigned, and occurred localization missing, it's not warned. + +**Default Value** + +`null` + +### modifiers + +**Signature:** +```typescript +modifiers?: Options['modifiers']; +``` + +**Details** + +Custom Modifiers for linked messages. + +**See Also** +- [Custom Modifiers](../guide/essentials/syntax#custom-modifiers) + +### number + +### numberFormats + +### pluralizationRules + +**Signature:** +```typescript +pluralizationRules?: Options['pluralRules']; +``` + +**Details** + +A set of rules for word pluralization + +**Default Value** + +`{}` + +**See Also** +- [Custom Pluralization](../guide/essentials/pluralization#custom-pluralization) + +### postTranslation + +**Signature:** +```typescript +postTranslation?: Options['postTranslation']; +``` + +**Details** + +A handler for post processing of translation. The handler gets after being called with the `$t`, and `t`. + +This handler is useful if you want to filter on translated text such as space trimming. + +**Default Value** + +`null` + +### sharedMessages + +**Signature:** +```typescript +sharedMessages?: LocaleMessages; +``` + +**Details** + +The shared locale messages of localization for components. More detail see Component based localization. + +**Default Value** + +`undefined` + +**See Also** +- [Shared locale messages for components](../guide/essentials/local#shared-locale-messages-for-components) + +### silentFallbackWarn + +**Signature:** +```typescript +silentFallbackWarn?: Options['fallbackWarn']; +``` + +**Details** + +Whether do template interpolation on translation keys when your language lacks a translation for a key. + +If `true`, skip writing templates for your "base" language; the keys are your templates. + +**Default Value** + +`false` + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### silentTranslationWarn + +**Signature:** +```typescript +silentTranslationWarn?: Options['missingWarn']; +``` + +**Details** + +Whether suppress warnings outputted when localization fails. + +If `true`, suppress localization fail warnings. + +If you use regular expression, you can suppress localization fail warnings that it match with translation key (e.g. `t`). + +**Default Value** + +`false` + +**See Also** +- [Fallbacking](../guide/essentials/fallback) + +### sync + +**Signature:** +```typescript +sync?: boolean; +``` + +**Details** + +Whether synchronize the root level locale to the component localization locale. + +If `false`, regardless of the root level locale, localize for each component locale. + +**Default Value** + +`true` + +**See Also** +- [Local Scope](../guide/essentials/scope#local-scope-2) + +### warnHtmlInMessage + +**Signature:** +```typescript +warnHtmlInMessage?: WarnHtmlInMessageLevel; +``` + +**Details** + +Whether to allow the use locale messages of HTML formatting. + +See the warnHtmlInMessage property. + +**Default Value** + +`'off'` + +**See Also** +- [HTML Message](../guide/essentials/syntax#html-message) +- [Change `warnHtmlInMessage` option default value](../guide/migration/breaking#change-warnhtmlinmessage-option-default-value) + +## VueI18nResolveLocaleMessageTranslation + +Resolve locale message translation functions for VueI18n legacy interfaces + +**Signature:** +```typescript +export type VueI18nResolveLocaleMessageTranslation = ComposerResolveLocaleMessageTranslation; +``` + +:::danger DEPRECATED +will be removed at vue-i18n v12 +::: + +**Details** + +This is the interface for [VueI18n](legacy#vuei18n). This interface is an alias of [ComposerResolveLocaleMessageTranslation](composition#composerresolvelocalemessagetranslation). + +## VueI18nTranslation + +Locale message translation functions for VueI18n legacy interfaces + +**Signature:** +```typescript +export interface VueI18nTranslation = {}, Locales = 'en-US', DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, C = IsEmptyObject extends false ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, M = IsEmptyObject extends false ? PickupKeys : never, ResourceKeys extends C | M = IsNever extends false ? IsNever extends false ? C | M : C : IsNever extends false ? M : never> +``` + +:::danger DEPRECATED +will be removed at vue-i18n v12 +::: + +**Details** + +This is the interface for [VueI18n](legacy#vuei18n) + +### (key: Key | ResourceKeys): TranslateResult; + +Locale message translation. + +**Signature:** +```typescript +(key: Key | ResourceKeys): TranslateResult; +``` + +**Details** + +If this is used in a reactive context, it will re-evaluate once the locale changes. + +If [i18n component options](injection#i18n) is specified, it’s translated in preferentially local scope locale messages than global scope locale messages. + +If [i18n component options](injection#i18n) isn't specified, it’s translated with global scope locale messages. + +**See Also** +- [Scope and Locale Changing](../guide/essentials/scope) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | A target locale message key | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys, named: Record<string, unknown>): TranslateResult; + +Locale message translation. + +**Signature:** +```typescript +(key: Key | ResourceKeys, named: Record): TranslateResult; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details. + +**See Also** +- [Named interpolation](../guide/essentials/syntax#named-interpolation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | A target locale message key | +| named | Record<string, unknown> | A values of named interpolation | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys, named: NamedValue, plural: number): TranslateResult; + +Locale message translation for named interpolations and plurals + +**Signature:** +```typescript +(key: Key | ResourceKeys, named: NamedValue, plural: number): TranslateResult; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details. + +In this overloaded `t`, for each placeholder x, the locale messages should contain a `{x}` token, and return a pluralized translation message. + +**See Also** +- [Pluralization](../guide/essentials/pluralization) +- [Named interpolation](../guide/essentials/syntax#named-interpolation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | A target locale message key | +| named | NamedValue | A values of named interpolation | +| plural | number | Which plural string to get. 1 returns the first one. | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys, named: NamedValue, defaultMsg: string): TranslateResult; + +Locale message translation for named interpolations and plurals + +**Signature:** +```typescript +(key: Key | ResourceKeys, named: NamedValue, defaultMsg: string): TranslateResult; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details. + +In this overloaded `t`, for each placeholder x, the locale messages should contain a `{x}` token, and if no translation was found, return a default message. + +**See Also** +- [Named interpolation](../guide/essentials/syntax#named-interpolation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | A target locale message key | +| named | NamedValue | A values of named interpolation | +| defaultMsg | string | A default message to return if no translation was found | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys, named: NamedValue, options: TranslateOptions<Locales>): TranslateResult; + +Locale message translation for named interpolations + +**Signature:** +```typescript +(key: Key | ResourceKeys, named: NamedValue, options: TranslateOptions): TranslateResult; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details. + +In this overloaded `t`, for each placeholder x, the locale messages should contain a `{x}` token. + +You can also suppress the warning, when the translation missing according to the options. + +About details of options, see the . + +**See Also** +- [Named interpolation](../guide/essentials/syntax#named-interpolation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | A target locale message key | +| named | NamedValue | A values of named interpolation | +| options | TranslateOptions<Locales> | Additional for translation | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys, plural: number): TranslateResult; + +Locale message translation for plurals + +**Signature:** +```typescript +(key: Key | ResourceKeys, plural: number): TranslateResult; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details. + +In this overloaded `t`, return a pluralized translation message. + +You can also suppress the warning, when the translation missing according to the options. + +**See Also** +- [Pluralization](../guide/essentials/pluralization) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | A target locale message key | +| plural | number | Which plural string to get. 1 returns the first one. | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys, plural: number, options: TranslateOptions<Locales>): TranslateResult; + +Locale message translation for plurals + +**Signature:** +```typescript +(key: Key | ResourceKeys, plural: number, options: TranslateOptions): TranslateResult; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details. + +In this overloaded `t`, return a pluralized translation message. + +You can also suppress the warning, when the translation missing according to the options. + +About details of options, see the . + +**See Also** +- [Pluralization](../guide/essentials/pluralization) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | A target locale message key | +| plural | number | Which plural string to get. 1 returns the first one. | +| options | TranslateOptions<Locales> | Additional for translation | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys, defaultMsg: string): TranslateResult; + +Locale message translation for missing default message + +**Signature:** +```typescript +(key: Key | ResourceKeys, defaultMsg: string): TranslateResult; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details. + +In this overloaded `t`, if no translation was found, return a default message. + +You can also suppress the warning, when the translation missing according to the options. + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | A target locale message key | +| defaultMsg | string | A default message to return if no translation was found | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys, defaultMsg: string, options: TranslateOptions<Locales>): TranslateResult; + +Locale message translation for missing default message + +**Signature:** +```typescript +(key: Key | ResourceKeys, defaultMsg: string, options: TranslateOptions): TranslateResult; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details. + +In this overloaded `t`, if no translation was found, return a default message. + +You can also suppress the warning, when the translation missing according to the options. + +About details of options, see the . + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | A target locale message key | +| defaultMsg | string | A default message to return if no translation was found | +| options | TranslateOptions<Locales> | Additional for translation | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys, list: unknown[]): TranslateResult; + +Locale message translation. + +**Signature:** +```typescript +(key: Key | ResourceKeys, list: unknown[]): TranslateResult; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details. + +**See Also** +- [List interpolation](../guide/essentials/syntax#list-interpolation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | A target locale message key | +| list | unknown[] | A values of list interpolation | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys, list: unknown[], plural: number): TranslateResult; + +Locale message translation for list interpolations and plurals + +**Signature:** +```typescript +(key: Key | ResourceKeys, list: unknown[], plural: number): TranslateResult; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details. + +In this overloaded `t`, the locale messages should contain a `{0}`, `{1}`, … for each placeholder in the list, and return a pluralized translation message. + +**See Also** +- [Pluralization](../guide/essentials/pluralization) +- [List interpolation](../guide/essentials/syntax#list-interpolation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | A target locale message key | +| list | unknown[] | A values of list interpolation | +| plural | number | Which plural string to get. 1 returns the first one. | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys, list: unknown[], defaultMsg: string): TranslateResult; + +Locale message translation for list interpolations and missing default message + +**Signature:** +```typescript +(key: Key | ResourceKeys, list: unknown[], defaultMsg: string): TranslateResult; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details. + +In this overloaded `t`, the locale messages should contain a `{0}`, `{1}`, … for each placeholder in the list, and if no translation was found, return a default message. + +**See Also** +- [List interpolation](../guide/essentials/syntax#list-interpolation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | A target locale message key | +| list | unknown[] | A values of list interpolation | +| defaultMsg | string | A default message to return if no translation was found | + +#### Returns + + Translated message + +### (key: Key | ResourceKeys, list: unknown[], options: TranslateOptions<Locales>): TranslateResult; + +Locale message translation for list interpolations + +**Signature:** +```typescript +(key: Key | ResourceKeys, list: unknown[], options: TranslateOptions): TranslateResult; +``` + +**Details** + +Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details. + +In this overloaded `t`, the locale messages should contain a `{0}`, `{1}`, … for each placeholder in the list. + +You can also suppress the warning, when the translation missing according to the options. + +About details of options, see the . + +**See Also** +- [List interpolation](../guide/essentials/syntax#list-interpolation) + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | ResourceKeys | A target locale message key | +| list | unknown[] | A values of list interpolation | +| options | TranslateOptions<Locales> | Additional for translation | + +#### Returns + + Translated message + +## WarnHtmlInMessageLevel + +**Signature:** +```typescript +export type WarnHtmlInMessageLevel = 'off' | 'warn' | 'error'; +``` + +:::danger DEPRECATED +will be removed at vue-i18n v12 +::: + diff --git a/docs/api/v11/injection.md b/docs/api/v11/injection.md new file mode 100644 index 000000000..68f4e526a --- /dev/null +++ b/docs/api/v11/injection.md @@ -0,0 +1,952 @@ +# Component Injections + + +## ComponentCustomOptions + +Component Custom Properties for Vue I18n + +**Signature:** +```typescript +export interface ComponentCustomOptions; +``` + +### i18n + +Vue I18n options for Component + +**Signature:** +```typescript +i18n?: VueI18nOptions; +``` + +**See Also** +- [VueI18nOptions](legacy#vuei18noptions) + +## ComponentCustomProperties + +Component Custom Options for Vue I18n + +**Signature:** +```typescript +export interface ComponentCustomProperties; +``` + +**Details** + +These properties are injected into every child component + +### $i18n + +Exported Global Composer instance, or global VueI18n instance. + +**Signature:** +```typescript +$i18n: VueI18n | ExportedGlobalComposer; +``` + +**Details** + +You can get the [exported composer instance](general#exportedglobalcomposer) which are exported from global [composer](composition#composer) instance created with [createI18n](general#createi18n), or global [VueI18n](legacy#vuei18n) instance. + +You can get the exported composer instance in [Composition API mode](general#mode), or the Vuei18n instance in [Legacy API mode](general#mode), which is the instance you can refer to with this property. + +The locales, locale messages, and other resources managed by the instance referenced by this property are valid as global scope. + +If the `i18n` component option is not specified, it’s the same as the VueI18n instance that can be referenced by the i18n instance [global](general#global). + +**See Also** +- [Scope and Locale Changing](../../guide/essentials/scope) +- [Composition API](../../guide/advanced/composition) + +### $t(key) + +Locale message translation + +**Signature:** +```typescript +$t(key: Key): TranslateResult; +``` + +**Details** + +If this is used in a reactive context, it will re-evaluate once the locale changes. + +In [Composition API mode](general#mode), the `$t` is injected by `app.config.globalProperties`. The input / output is the same as for Composer, and it works on **global scope**. About that details, see [Composer#t](composition#t-key). + +In [Legacy API mode](general#mode), the input / output is the same as for VueI18n instance. About details, see [VueI18n#t](legacy#t-key). + +**See Also** +- [Scope and Locale Changing](../../guide/essentials/scope) +- [Composition API](../../guide/advanced/composition) + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | + +#### Returns + +Translation message + +### $t(key, locale) + +:::danger NOTICE +**This API signature is available in Legacy API mode only and is supported until v9**. +::: + +Locale message translation + +**Signature:** +```typescript +$t(key: Key, locale: Locale): TranslateResult; +``` + +**Details** + +Overloaded `$t`. About details, see the [$t](injection#t-key) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | +| locale | Locale | A locale, override locale that global scope or local scope | + +#### Returns + +Translation message + +### $t(key, locale, list) + +:::danger NOTICE +**This API signature is available in Legacy API mode only and is supported until v9**. +::: + +Locale message translation + +**Signature:** +```typescript +$t(key: Key, locale: Locale, list: unknown[]): TranslateResult; +``` + +**Details** + +Overloaded `$t`. About details, see the [$t](injection#t-key) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | +| locale | Locale | A locale, override locale that global scope or local scope | +| list | unknown[] | A values of list interpolation | + +#### Returns + +Translation message + +### $t(key, locale, named) + +:::danger NOTICE +**This API signature is available in Legacy API mode only and is supported until v9**. +::: + +Locale message translation + +**Signature:** +```typescript +$t(key: Key, locale: Locale, named: object): TranslateResult; +``` + +**Details** + +Overloaded `$t`. About details, see the [$t](injection#t-key) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | +| locale | Locale | A locale, override locale that global scope or local scope | +| named | object | A values of named interpolation | + +#### Returns + +Translation message + +### $t(key, plural) + +Locale message translation + +**Signature:** +```typescript +$t(key: Key, plural: number): TranslateResult; +``` + +:::tip NOTE +Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**. +::: + +**Details** + +Overloaded `$t`. About details, see the [$t](injection#t-key) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | +| plural | number | A choice number of plural | + +#### Returns + +Translation message + +### $t(key, plural, options) + +Locale message translation + +**Signature:** +```typescript +$t(key: Key, plural: number, options: TranslateOptions): TranslateResult; +``` + +:::tip NOTE +Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**. +::: + +**Details** + +Overloaded `$t`. About details, see the [$t](injection#t-key) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | +| plural | number | A choice number of plural | +| options | TranslateOptions | An options, see the [TranslateOptions](general#translateoptions) | + +#### Returns + +Translation message + +### $t(key, defaultMsg) + +Locale message translation + +**Signature:** +```typescript +$t(key: Key, defaultMsg: string): TranslateResult; +``` + +:::tip NOTE +Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**. +::: + +**Details** + +Overloaded `$t`. About details, see the [$t](injection#t-key) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | +| defaultMsg | string | A default message to return if no translation was found | + +#### Returns + +Translation message + +### $t(key, defaultMsg, options) + +Locale message translation + +**Signature:** +```typescript +$t(key: Key, defaultMsg: string, options: TranslateOptions): TranslateResult; +``` + +:::tip NOTE +Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**. +::: + +**Details** + +Overloaded `$t`. About details, see the [$t](injection#t-key) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | +| defaultMsg | string | A default message to return if no translation was found | +| options | TranslateOptions | An options, see the [TranslateOptions](general#translateoptions) | + +#### Returns + +Translation message + +### $t(key, list) + +Locale message translation + +**Signature:** +```typescript +$t(key: Key, list: unknown[]): TranslateResult; +``` + +**Details** + +Overloaded `$t`. About details, see the [$t](injection#t-key) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | +| list | unknown[] | A values of list interpolation | + +#### Returns + +Translation message + +### $t(key, list, plural) + +Locale message translation + +**Signature:** +```typescript +$t(key: Key, list: unknown[], plural: number): TranslateResult; +``` + +:::tip NOTE +Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**. +::: + +**Details** + +Overloaded `$t`. About details, see the [$t](injection#t-key) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | +| list | unknown[] | A values of list interpolation | +| plural | number | A choice number of plural | + +#### Returns + +Translation message + +### $t(key, list, defaultMsg) + +Locale message translation + +**Signature:** +```typescript +$t(key: Key, list: unknown[], defaultMsg: string): TranslateResult; +``` + +:::tip NOTE +Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**. +::: + +**Details** + +Overloaded `$t`. About details, see the [$t](injection#t-key) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | +| list | unknown[] | A values of list interpolation | +| defaultMsg | string | A default message to return if no translation was found | + +#### Returns + +Translation message + +### $t(key, list, options) + +Locale message translation + +**Signature:** +```typescript +$t(key: Key, list: unknown[], options: TranslateOptions): TranslateResult; +``` + +:::tip NOTE +Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**. +::: + +**Details** + +Overloaded `$t`. About details, see the [$t](injection#t-key) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | +| list | unknown[] | A values of list interpolation | +| options | TranslateOptions | An options, see the [TranslateOptions](general#translateoptions) | + +#### Returns + +Translation message + +### $t(key, named) + +Locale message translation + +**Signature:** +```typescript +$t(key: Key, named: NamedValue): TranslateResult; +``` + +**Details** + +Overloaded `$t`. About details, see the [$t](injection#t-key) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | +| named | NamedValue | A values of named interpolation | + +#### Returns + +Translation message + +### $t(key, named, plural) + +Locale message translation + +**Signature:** +```typescript +$t(key: Key, named: NamedValue, plural: number): TranslateResult; +``` + +:::tip NOTE +Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**. +::: + +**Details** + +Overloaded `$t`. About details, see the [$t](injection#t-key) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | +| named | NamedValue | A values of named interpolation | +| plural | number | A choice number of plural | + +#### Returns + +Translation message + +### $t(key, named, defaultMsg) + +Locale message translation + +**Signature:** +```typescript +$t(key: Key, named: NamedValue, defaultMsg: string): TranslateResult; +``` + +:::tip NOTE +Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**. +::: + +**Details** + +Overloaded `$t`. About details, see the [$t](injection#t-key) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | +| named | NamedValue | A values of named interpolation | +| defaultMsg | string | A default message to return if no translation was found | + +#### Returns + +Translation message + +### $t(key, named, options) + +Locale message translation + +**Signature:** +```typescript +$t(key: Key, named: NamedValue, options: TranslateOptions): TranslateResult; +``` + +:::tip NOTE +Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**. +::: + +**Details** + +Overloaded `$t`. About details, see the [$t](injection#t-key) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | +| named | NamedValue | A values of named interpolation | +| options | TranslateOptions | An options, see the [TranslateOptions](general#translateoptions) | + +#### Returns + +Translation message + +### $rt(message) + +Resolve locale message translation + +**Signature:** +```typescript +$rt(message: MessageFunction | VueMessageType): string; +``` + +**Details** + +If this is used in a reactive context, it will re-evaluate once the locale changes. + +In [Composition API mode](general#mode), the `$rt` is injected by `app.config.globalProperties`. The input / output is the same as for Composer, and it works on **global scope**. About that details, see [Composer#rt](composition#rt-message). + +In [Legacy API mode](general#mode), the input / output is the same as for VueI18n instance. About details, see [VueI18n#rt](legacy#rt-message). + +**See Also** +- [Scope and Locale Changing](../../guide/essentials/scope) +- [Composition API](../../guide/advanced/composition) + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| message | MessageFunction<VueMessageType> \| VueMessageType | A target locale message to be resolved. You will need to specify the locale message returned by `$tm`. | + +#### Returns + +Translation message + +### $rt(message, plural, options) + +Resolve locale message translation for plurals + +**Signature:** +```typescript +$rt(message: MessageFunction | VueMessageType, plural: number, options?: TranslationOptions): string; +``` + +**Details** + +Overloaded `$rt`. About details, see the [$rt](injection#rt-message) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| message | MessageFunction<VueMessageType> \| VueMessageType | A target locale message to be resolved. You will need to specify the locale message returned by `$tm`. | +| plural | number | Which plural string to get. `1` returns the first one. | +| options | TranslateOptions | Additional [TranslateOptions](general#translateoptions) | + +#### Returns + +Translation message + +### $rt(message, list, options) + +Resolve locale message translation for list interpolations + +**Signature:** +```typescript +$rt(message: MessageFunction | VueMessageType, list: unknown[], options?: TranslationOptions): string; +``` + +**Details** + +Overloaded `$rt`. About details, see the [$rt](injection#rt-message) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| message | MessageFunction<VueMessageType> \| VueMessageType | A target locale message to be resolved. You will need to specify the locale message returned by `$tm`. | +| list | unknown[] | A values of list interpolation. | +| options | TranslateOptions | Additional [TranslateOptions](general#translateoptions) | + +#### Returns + +Translation message + +### $rt(message, named, options) + +Resolve locale message translation for named interpolations + +**Signature:** +```typescript +$rt(message: MessageFunction | VueMessageType, named: NamedValue, options?: TranslationOptions): string; +``` + +**Details** + +Overloaded `$rt`. About details, see the [$rt](injection#rt-message) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| message | MessageFunction<VueMessageType> \| VueMessageType | A target locale message to be resolved. You will need to specify the locale message returned by `$tm`. | +| named | NamedValue | A values of named interpolation. | +| options | TranslateOptions | Additional [TranslateOptions](general#translateoptions) | + +#### Returns + +Translation message + +### $te(key, locale) + +Translation message exist + +**Signature:** +```typescript +$te(key: Key, locale?: Locale): boolean; +``` + +**Details** + +About that details, see [VueI18n#te](legacy#te-key-locale) + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | +| locale | Locale | Optional, A locale, override locale that global scope or local scope | + +#### Returns + +If found locale message, `true`, else `false`. + +### $tm(key) + +Locale messages getter + +**Signature:** +```typescript +$tm(key: Key): LocaleMessageValue | {} +``` + +**Details** + +If [i18n component options](injection#i18n) is specified, it’s get in preferentially local scope locale messages than global scope locale messages. + +If [i18n component options](injection#i18n) isn’t specified, it’s get with global scope locale messages. + +Based on the current `locale`, locale messages will be returned from Composer instance messages. + +If you change the `locale`, the locale messages returned will also correspond to the locale. + +If there are no locale messages for the given `key` in the composer instance messages, they will be returned with [fallbacking](../../guide/essentials/fallback). + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| key | Key | A target locale message key | + +#### Returns + +Locale messages + +:::warning NOTE +You need to use `$rt` for the locale message returned by `$tm`. +::: + +### $d(value) + +Datetime formatting + +**Signature:** +```typescript +$d(value: number | Date): DateTimeFormatResult | string; +``` + +**Details** + +If this is used in a reactive context, it will re-evaluate once the locale changes. + +In [Composition API mode](general#i18nmode), the input / output is the same as for VueI18n instance. About details, see [VueI18n#d](legacy#d-value). + +In [Composition API mode](general#i18nmode), the `$d` is injected by `app.config.globalProperties`. The input / output is the same as for Composer instance, and it works on **global scope**. About that details, see [Composer#d](composition#d-value). + +**See Also** +- [Datetime Formatting](../../guide/essentials/datetime) +- [Scope and Locale Changing](../../guide/essentials/scope) +- [Composition API](../../guide/advanced/composition#datetime-formatting) + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| value | number \| Date | A value, timestamp number or `Date` instance | + +#### Returns + +Formatted value + +### $d(value, key) + +Datetime formatting + +**Signature:** +```typescript +$d(value: number | Date, key: string): DateTimeFormatResult | string; +``` + +**Details** + +Overloaded `$d`. About details, see the [$d](injection#d-value) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| value | number \| Date | A value, timestamp number or `Date` instance | +| key | string | A key of datetime formats | + +#### Returns + +Formatted value + +### $d(value, key, locale) + +Datetime formatting + +**Signature:** +```typescript +$d(value: number | Date, key: string, locale: Locale): DateTimeFormatResult | string; +``` + +**Details** + +Overloaded `$d`. About details, see the [$d](injection#d-value) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| value | number \| Date | A value, timestamp number or `Date` instance | +| key | string | A key of datetime formats | +| locale | Locale | A locale, override locale that global scope or local scope | + +#### Returns + +Formatted value + +### $d(value, args) + +Datetime formatting + +**Signature:** +```typescript +$d(value: number | Date, args: { [key: string]: string | boolean | number }): DateTimeFormatResult; +``` + +**Details** + +Overloaded `$d`. About details, see the [$d](injection#d-value) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| value | number \| Date | A value, timestamp number or `Date` instance | +| args | { [key: string]: string } | An argument values | + +#### Returns + +Formatted value + +### $d(value, options) + +Datetime formatting + +**Signature:** +```typescript +$d(value: number | Date, options: DateTimeOptions): string; +``` + +**Details** + +Overloaded `$d`. About details, see the [$d](injection#d-value) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| value | number \| Date | A value, timestamp number or `Date` instance | +| options | DateTimeOptions | An options, see the [DateTimeOptions](general#datetimeoptions) | + +#### Returns + +Formatted value + +### $n(value) + +Number formatting + +**Signature:** +```typescript +$n(value: number): NumberFormatResult | string; +``` + +**Details** + +If this is used in a reactive context, it will re-evaluate once the locale changes. + +In [Legacy API mode](general#i18nmode), the input / output is the same as for VueI18n instance. About details, see [VueI18n#n](legacy#n-value). + +In [Composition API mode](general#i18nmode), the `$n` is injected by `app.config.globalProperties`. The input / output is the same as for Composer instance, and it works on **global scope**. About that details, see [Composer#n](composition#n-value). + +**See Also** +- [Number Formatting](../../guide/essentials/number) +- [Scope and Locale Changing](../../guide/essentials/scope) +- [Composition API](../../guide/advanced/composition#number-formatting) + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | A number value | + +#### Returns + +Formatted value + +### $n(value, key) + +Number formatting + +**Signature:** +```typescript +$n(value: number, key: string): NumberFormatResult | string; +``` + +**Details** + +Overloaded `$n`. About details, see the [$n](injection#n-value) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | A number value | +| key | string | A key of number formats | + +#### Returns + +Formatted value + +### $n(value, key, locale) + +Number formatting + +**Signature:** +```typescript +$n(value: number, key: string, locale: Locale): NumberFormatResult | string; +``` + +**Details** + +Overloaded `$n`. About details, see the [$n](injection#n-value) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | A number value | +| key | string | A key of number formats | +| locale | Locale | A locale, override locale that global scope or local scope | + +#### Returns + +Formatted value + +### $n(value, args) + +Number formatting + +**Signature:** +```typescript +$n(value: number, args: { [key: string]: string | boolean | number }): NumberFormatResult; +``` + +**Details** + +Overloaded `$n`. About details, see the [$n](injection#n-value) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | A number value | +| args | { [key: string]: string } | An argument values | + +#### Returns + +Formatted value + +### $n(value, key, args) + +Number formatting + +**Signature:** +```typescript +$n(value: number, key: string, args: { [key: string]: string | boolean | number }): NumberFormatResult +``` + +**Details** + +Overloaded `$n`. About details, see the [$n](injection#n-value) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | A number value | +| key | string | A key of number formats | +| args | { [key: string]: string } | An argument values | + +#### Returns + +Formatted value + +### $n(value, key, locale, args) + +Number formatting + +**Signature:** +```typescript +$n(value: number, key: string, locale: Locale, args: { [key: string]: string | boolean | number }): NumberFormatResult +``` + +**Details** + +Overloaded `$n`. About details, see the [$n](injection#n-value) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | A number value | +| key | string | A key of number formats | +| locale | Locale | A locale, override locale that global scope or local scope | +| args | { [key: string]: string } | An argument values | + +#### Returns + +Formatted value + +### $n(value, options) + +Number formatting + +**Signature:** +```typescript +$n(value: number, options: NumberOptions): string; +``` + +**Details** + +Overloaded `$n`. About details, see the [$n](injection#n-value) remarks. + +#### Parameters +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | A number value | +| options | NumberOptions | An options, see the [NumberOptions](general#numberoptions) | + +#### Returns + +Formatted value diff --git a/package.json b/package.json index dd785249b..35058bf5e 100644 --- a/package.json +++ b/package.json @@ -45,9 +45,11 @@ "dev:size-core": "pnpm --filter @intlify/size-check-core dev", "dev:size-petite-vue-i18n": "pnpm --filter @intlify/size-check-petite-vue-i18n dev", "dev:size-vue-i18n": "pnpm --filter @intlify/size-check-vue-i18n dev", - "docs:apigen": "pnpm docs:apigen:core && pnpm docs:apigen:vue", + "docs:apigen": "pnpm docs:apigen:core:v11 && pnpm docs:apigen:vue:v11", "docs:apigen:core": "api-docs-gen ./temp/core-base.api.json -o ./docs/api -c ./docsgen.config.js -g noprefix -t ./tsdoc.json && mv ./docs/api/general.md ./docs/api/temp.md", + "docs:apigen:core:v11": "api-docs-gen ./temp/core-base.api.json -o ./docs/api/v11 -c ./docsgen.config.js -g noprefix -t ./tsdoc.json && mv ./docs/api/v11/general.md ./docs/api/v11/temp.md", "docs:apigen:vue": "api-docs-gen ./temp/vue-i18n-core.api.json -o ./docs/api -c ./docsgen.config.js -g noprefix -t ./tsdoc.json && tail -n +3 ./docs/api/temp.md >> ./docs/api/general.md && rm -rf ./docs/api/temp.md", + "docs:apigen:vue:v11": "api-docs-gen ./temp/vue-i18n-core.api.json -o ./docs/api/v11 -c ./docsgen.config.js -g noprefix -t ./tsdoc.json && tail -n +3 ./docs/api/v11/temp.md >> ./docs/api/v11/general.md && rm -rf ./docs/api/v11/temp.md", "docs:build": "pnpm docs:setup && vitepress build docs", "docs:dev": "vitepress dev docs", "docs:serve": "vitepress serve docs", diff --git a/packages/core-base/src/fallbacker.ts b/packages/core-base/src/fallbacker.ts index bb8a14868..4f9eeb3c6 100644 --- a/packages/core-base/src/fallbacker.ts +++ b/packages/core-base/src/fallbacker.ts @@ -1,17 +1,17 @@ import { - isString, isArray, isBoolean, - isPlainObject, + isFunction, isObject, + isPlainObject, isPromise, - isFunction + isString } from '@intlify/shared' import { DEFAULT_LOCALE } from './context' import { CoreErrorCodes, createCoreError } from './errors' -import type { Locale, LocaleDetector, FallbackLocale } from './runtime' import type { CoreContext, CoreInternalContext } from './context' +import type { FallbackLocale, Locale, LocaleDetector } from './runtime' /** @VueI18nGeneral */ export interface LocaleOptions { @@ -116,7 +116,7 @@ export function fallbackWithSimple( * * @returns Fallback locales * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) * * @VueI18nGeneral */ diff --git a/packages/vue-i18n-core/src/components/DatetimeFormat.ts b/packages/vue-i18n-core/src/components/DatetimeFormat.ts index 04618565f..1a98b6e80 100644 --- a/packages/vue-i18n-core/src/components/DatetimeFormat.ts +++ b/packages/vue-i18n-core/src/components/DatetimeFormat.ts @@ -72,7 +72,7 @@ export const DatetimeFormatImpl = /* #__PURE__*/ defineComponent({ * * @VueI18nSee [FormattableProps](component#formattableprops) * @VueI18nSee [BaseFormatProps](component#baseformatprops) - * @VueI18nSee [Custom Formatting](../guide/essentials/datetime#custom-formatting) + * @VueI18nSee [Custom Formatting](../../guide/essentials/datetime#custom-formatting) * * @VueI18nDanger * Not supported IE, due to no support `Intl.DateTimeFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts) diff --git a/packages/vue-i18n-core/src/components/NumberFormat.ts b/packages/vue-i18n-core/src/components/NumberFormat.ts index 71d747ae6..75cf887af 100644 --- a/packages/vue-i18n-core/src/components/NumberFormat.ts +++ b/packages/vue-i18n-core/src/components/NumberFormat.ts @@ -77,7 +77,7 @@ export const NumberFormatImpl = /*#__PURE__*/ defineComponent({ * * @VueI18nSee [FormattableProps](component#formattableprops) * @VueI18nSee [BaseFormatProps](component#baseformatprops) - * @VueI18nSee [Custom Formatting](../guide/essentials/number#custom-formatting) + * @VueI18nSee [Custom Formatting](../../guide/essentials/number#custom-formatting) * * @VueI18nDanger * Not supported IE, due to no support `Intl.NumberFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts) diff --git a/packages/vue-i18n-core/src/components/Translation.ts b/packages/vue-i18n-core/src/components/Translation.ts index d91c7e852..bb11b3a94 100644 --- a/packages/vue-i18n-core/src/components/Translation.ts +++ b/packages/vue-i18n-core/src/components/Translation.ts @@ -96,7 +96,7 @@ export const TranslationImpl = /*#__PURE__*/ defineComponent({ * * @VueI18nSee [TranslationProps](component#translationprops) * @VueI18nSee [BaseFormatProps](component#baseformatprops) - * @VueI18nSee [Component Interpolation](../guide/advanced/component) + * @VueI18nSee [Component Interpolation](../../guide/advanced/component) * * @example * ```html diff --git a/packages/vue-i18n-core/src/composer.ts b/packages/vue-i18n-core/src/composer.ts index 4774fc3d7..a00bb7bc7 100644 --- a/packages/vue-i18n-core/src/composer.ts +++ b/packages/vue-i18n-core/src/composer.ts @@ -312,7 +312,7 @@ export interface ComposerOptions< * * If the locale contains a territory and a dialect, this locale contains an implicit fallback. * - * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope) + * @VueI18nSee [Scope and Locale Changing](../../guide/essentials/scope) * * @defaultValue `'en-US'` */ @@ -323,7 +323,7 @@ export interface ComposerOptions< * * For more complex fallback definitions see fallback. * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) * * @defaultValue The default `'en-US'` for the `locale` if it's not specified, or it's `locale` value */ @@ -334,7 +334,7 @@ export interface ComposerOptions< * * If `false`, regardless of the root level locale, localize for each component locale. * - * @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-2) + * @VueI18nSee [Local Scope](../../guide/essentials/scope#local-scope-2) * * @defaultValue `true` */ @@ -343,7 +343,7 @@ export interface ComposerOptions< * @remarks * The locale messages of localization. * - * @VueI18nSee [Getting Started](../guide/essentials/started) + * @VueI18nSee [Getting Started](../../guide/essentials/started) * * @defaultValue `{}` */ @@ -359,7 +359,7 @@ export interface ComposerOptions< * @remarks * The datetime formats of localization. * - * @VueI18nSee [Datetime Formatting](../guide/essentials/datetime) + * @VueI18nSee [Datetime Formatting](../../guide/essentials/datetime) * * @defaultValue `{}` */ @@ -368,7 +368,7 @@ export interface ComposerOptions< * @remarks * The number formats of localization. * - * @VueI18nSee [Number Formatting](../guide/essentials/number) + * @VueI18nSee [Number Formatting](../../guide/essentials/number) * * @defaultValue `{}` */ @@ -377,14 +377,14 @@ export interface ComposerOptions< * @remarks * Custom Modifiers for linked messages. * - * @VueI18nSee [Custom Modifiers](../guide/essentials/syntax#custom-modifiers) + * @VueI18nSee [Custom Modifiers](../../guide/essentials/syntax#custom-modifiers) */ modifiers?: LinkedModifiers /** * @remarks * A set of rules for word pluralization * - * @VueI18nSee [Custom Pluralization](../guide/essentials/pluralization#custom-pluralization) + * @VueI18nSee [Custom Pluralization](../../guide/essentials/pluralization#custom-pluralization) * * @defaultValue `{}` */ @@ -408,7 +408,7 @@ export interface ComposerOptions< * * If you use regular expression, you can suppress localization fail warnings that it match with translation key (e.g. `t`). * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) * * @defaultValue `true` */ @@ -421,7 +421,7 @@ export interface ComposerOptions< * * If you use regular expression, you can suppress fallback warnings that it match with translation key (e.g. `t`). * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) * * @defaultValue `true` */ @@ -432,7 +432,7 @@ export interface ComposerOptions< * * If `false`, it's not fallback to root. * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) * * @defaultValue `true` */ @@ -443,7 +443,7 @@ export interface ComposerOptions< * * If `true`, skip writing templates for your "base" language; the keys are your templates. * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) * * @defaultValue `false` */ @@ -465,8 +465,8 @@ export interface ComposerOptions< * * See the warnHtmlMessage property. * - * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message) - * @VueI18nSee [Change `warnHtmlInMessage` option default value](../guide/migration/breaking#change-warnhtmlinmessage-option-default-value) + * @VueI18nSee [HTML Message](../../guide/essentials/syntax#html-message) + * @VueI18nSee [Change `warnHtmlInMessage` option default value](../../guide/migration/breaking#change-warnhtmlinmessage-option-default-value) * * @defaultValue `'off'` */ @@ -483,7 +483,7 @@ export interface ComposerOptions< * * Setting `escapeParameter` as true should not break existing functionality but provides a safeguard against a subtle type of XSS attack vectors. * - * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message) + * @VueI18nSee [HTML Message](../../guide/essentials/syntax#html-message) * * @defaultValue `false` */ @@ -545,7 +545,7 @@ export interface ComposerOptions< * @VueI18nWarning * If you use the message resolver, the [`flatJson`](composition#flatjson) setting will be ignored. That is, you need to resolve the flat JSON by yourself. * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) * * @defaultValue `undefined` */ @@ -607,7 +607,7 @@ export interface ComposerOptions< * @VueI18nWarning * The Custom Message Format is an experimental feature. It may receive breaking changes or be removed in the future. * - * @VueI18nSee [Custom Message Format](../guide/advanced/format) + * @VueI18nSee [Custom Message Format](../../guide/advanced/format) * * @defaultValue `undefined` */ @@ -671,7 +671,7 @@ export interface ComposerTranslation< * * @returns Translated message * - * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope) + * @VueI18nSee [Scope and Locale Changing](../../guide/essentials/scope) */ (key: Key | ResourceKeys | number): string /** @@ -689,7 +689,7 @@ export interface ComposerTranslation< * * @returns Translated message * - * @VueI18nSee [Pluralization](../guide/essentials/pluralization) + * @VueI18nSee [Pluralization](../../guide/essentials/pluralization) */ (key: Key | ResourceKeys | number, plural: number): string /** @@ -710,7 +710,7 @@ export interface ComposerTranslation< * * @returns Translated message * - * @VueI18nSee [Pluralization](../guide/essentials/pluralization) + * @VueI18nSee [Pluralization](../../guide/essentials/pluralization) */ ( key: Key | ResourceKeys | number, @@ -774,7 +774,7 @@ export interface ComposerTranslation< * * @returns Translated message * - * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation) + * @VueI18nSee [List interpolation](../../guide/essentials/syntax#list-interpolation) */ ( key: Key | ResourceKeys | number, @@ -794,8 +794,8 @@ export interface ComposerTranslation< * * @returns Translated message * - * @VueI18nSee [Pluralization](../guide/essentials/pluralization) - * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation) + * @VueI18nSee [Pluralization](../../guide/essentials/pluralization) + * @VueI18nSee [List interpolation](../../guide/essentials/syntax#list-interpolation) */ ( key: Key | ResourceKeys | number, @@ -816,7 +816,7 @@ export interface ComposerTranslation< * * @returns Translated message * - * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation) + * @VueI18nSee [List interpolation](../../guide/essentials/syntax#list-interpolation) */ ( key: Key | ResourceKeys | number, @@ -841,7 +841,7 @@ export interface ComposerTranslation< * * @returns Translated message * - * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation) + * @VueI18nSee [List interpolation](../../guide/essentials/syntax#list-interpolation) */ ( key: Key | ResourceKeys | number, @@ -863,7 +863,7 @@ export interface ComposerTranslation< * * @returns Translated message * - * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation) + * @VueI18nSee [Named interpolation](../../guide/essentials/syntax#named-interpolation) */ ( key: Key | ResourceKeys | number, @@ -883,8 +883,8 @@ export interface ComposerTranslation< * * @returns Translated message * - * @VueI18nSee [Pluralization](../guide/essentials/pluralization) - * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation) + * @VueI18nSee [Pluralization](../../guide/essentials/pluralization) + * @VueI18nSee [Named interpolation](../../guide/essentials/syntax#named-interpolation) */ ( key: Key | ResourceKeys | number, @@ -905,7 +905,7 @@ export interface ComposerTranslation< * * @returns Translated message * - * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation) + * @VueI18nSee [Named interpolation](../../guide/essentials/syntax#named-interpolation) */ ( key: Key | ResourceKeys | number, @@ -930,7 +930,7 @@ export interface ComposerTranslation< * * @returns Translated message * - * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation) + * @VueI18nSee [Named interpolation](../../guide/essentials/syntax#named-interpolation) */ ( key: Key | ResourceKeys | number, @@ -968,7 +968,7 @@ export interface ComposerResolveLocaleMessageTranslation { * * @returns Translated message * - * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope) + * @VueI18nSee [Scope and Locale Changing](../../guide/essentials/scope) */ (message: MessageFunction | VueMessageType): string /** @@ -991,7 +991,7 @@ export interface ComposerResolveLocaleMessageTranslation { * * @returns Translated message * - * @VueI18nSee [Pluralization](../guide/essentials/pluralization) + * @VueI18nSee [Pluralization](../../guide/essentials/pluralization) */ ( message: MessageFunction | VueMessageType, @@ -1018,7 +1018,7 @@ export interface ComposerResolveLocaleMessageTranslation { * * @returns Translated message * - * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation) + * @VueI18nSee [List interpolation](../../guide/essentials/syntax#list-interpolation) */ ( message: MessageFunction | VueMessageType, @@ -1045,7 +1045,7 @@ export interface ComposerResolveLocaleMessageTranslation { * * @returns Translated message * - * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation) + * @VueI18nSee [Named interpolation](../../guide/essentials/syntax#named-interpolation) */ ( message: MessageFunction | VueMessageType, @@ -1097,7 +1097,7 @@ export interface ComposerDateTimeFormatting< * * @returns Formatted value * - * @VueI18nSee [Datetime formatting](../guide/essentials/datetime) + * @VueI18nSee [Datetime formatting](../../guide/essentials/datetime) */ (value: number | Date | string): string /** @@ -1187,7 +1187,7 @@ export interface ComposerNumberFormatting< * * @returns Formatted value * - * @VueI18nSee [Number formatting](../guide/essentials/number) + * @VueI18nSee [Number formatting](../../guide/essentials/number) */ (value: number): string /** @@ -1294,21 +1294,21 @@ export interface Composer< * * If the locale contains a territory and a dialect, this locale contains an implicit fallback. * - * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope) + * @VueI18nSee [Scope and Locale Changing](../../guide/essentials/scope) */ locale: WritableComputedRef /** * @remarks * The current fallback locales this Composer instance is using. * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) */ fallbackLocale: WritableComputedRef> /** * @remarks * Whether inherit the root level locale to the component localization locale. * - * @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-2) + * @VueI18nSee [Local Scope](../../guide/essentials/scope#local-scope-2) */ inheritLocale: boolean /** @@ -1320,14 +1320,14 @@ export interface Composer< * @remarks * The locale messages of localization. * - * @VueI18nSee [Getting Started](../guide/essentials/started) + * @VueI18nSee [Getting Started](../../guide/essentials/started) */ readonly messages: ComputedRef<{ [K in keyof Messages]: Messages[K] }> /** * @remarks * The datetime formats of localization. * - * @VueI18nSee [Datetime Formatting](../guide/essentials/datetime) + * @VueI18nSee [Datetime Formatting](../../guide/essentials/datetime) */ readonly datetimeFormats: ComputedRef<{ [K in keyof DateTimeFormats]: DateTimeFormats[K] @@ -1336,7 +1336,7 @@ export interface Composer< * @remarks * The number formats of localization. * - * @VueI18nSee [Number Formatting](../guide/essentials/number) + * @VueI18nSee [Number Formatting](../../guide/essentials/number) */ readonly numberFormats: ComputedRef<{ [K in keyof NumberFormats]: NumberFormats[K] @@ -1345,14 +1345,14 @@ export interface Composer< * @remarks * Custom Modifiers for linked messages. * - * @VueI18nSee [Custom Modifiers](../guide/essentials/syntax#custom-modifiers) + * @VueI18nSee [Custom Modifiers](../../guide/essentials/syntax#custom-modifiers) */ readonly modifiers: LinkedModifiers /** * @remarks * A set of rules for word pluralization * - * @VueI18nSee [Custom Pluralization](../guide/essentials/pluralization#custom-pluralization) + * @VueI18nSee [Custom Pluralization](../../guide/essentials/pluralization#custom-pluralization) */ readonly pluralRules: PluralizationRules /** @@ -1364,28 +1364,28 @@ export interface Composer< * @remarks * Whether suppress warnings outputted when localization fails. * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) */ missingWarn: boolean | RegExp /** * @remarks * Whether suppress fall back warnings when localization fails. * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) */ fallbackWarn: boolean | RegExp /** * @remarks * Whether to fall back to root level (global scope) localization when localization fails. * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) */ fallbackRoot: boolean /** * @remarks * Whether suppress warnings when falling back to either `fallbackLocale` or root. * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) */ fallbackFormat: boolean /** @@ -1396,15 +1396,15 @@ export interface Composer< * * If you are specified `true`, a warning will be output at console. * - * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message) - * @VueI18nSee [Change `warnHtmlInMessage` option default value](../guide/migration/breaking#change-warnhtmlinmessage-option-default-value) + * @VueI18nSee [HTML Message](../../guide/essentials/syntax#html-message) + * @VueI18nSee [Change `warnHtmlInMessage` option default value](../../guide/migration/breaking#change-warnhtmlinmessage-option-default-value) */ warnHtmlMessage: boolean /** * @remarks * Whether interpolation parameters are escaped before the message is translated. * - * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message) + * @VueI18nSee [HTML Message](../../guide/essentials/syntax#html-message) */ escapeParameter: boolean /** @@ -1483,7 +1483,7 @@ export interface Composer< * * If you change the `locale`, the locale messages returned will also correspond to the locale. * - * If there are no locale messages for the given `key` in the composer instance messages, they will be returned with [fallbacking](../guide/essentials/fallback). + * If there are no locale messages for the given `key` in the composer instance messages, they will be returned with [fallbacking](../../guide/essentials/fallback). * * @VueI18nWarning * You need to use `rt` for the locale message returned by `tm`. see the [rt](composition#rt-message) details. diff --git a/packages/vue-i18n-core/src/i18n.ts b/packages/vue-i18n-core/src/i18n.ts index 1fc5eec4f..696fe66df 100644 --- a/packages/vue-i18n-core/src/i18n.ts +++ b/packages/vue-i18n-core/src/i18n.ts @@ -129,7 +129,7 @@ export interface I18nAdditionalOptions { * * @deprecated will be removed at vue-i18n v12 * - * @VueI18nSee [Composition API](../guide/advanced/composition) + * @VueI18nSee [Composition API](../../guide/advanced/composition) * * @defaultValue `true` */ @@ -140,7 +140,7 @@ export interface I18nAdditionalOptions { * @remarks * If set to `true`, then properties and methods prefixed with `$` are injected into Vue Component. * - * @VueI18nSee [Implicit with injected properties and functions](../guide/advanced/composition#implicit-with-injected-properties-and-functions) + * @VueI18nSee [Implicit with injected properties and functions](../../guide/advanced/composition#implicit-with-injected-properties-and-functions) * @VueI18nSee [ComponentCustomProperties](injection#componentcustomproperties) * * @defaultValue `true` @@ -382,8 +382,8 @@ export function createI18n< * * If you use composition API mode, you need to specify {@link ComposerOptions}. * - * @VueI18nSee [Getting Started](../guide/essentials/started) - * @VueI18nSee [Composition API](../guide/advanced/composition) + * @VueI18nSee [Getting Started](../../guide/essentials/started) + * @VueI18nSee [Composition API](../../guide/advanced/composition) * * @example * case: for Legacy API diff --git a/packages/vue-i18n-core/src/legacy.ts b/packages/vue-i18n-core/src/legacy.ts index 9d5dace6b..1801a557f 100644 --- a/packages/vue-i18n-core/src/legacy.ts +++ b/packages/vue-i18n-core/src/legacy.ts @@ -140,7 +140,7 @@ export interface VueI18nOptions< * * If the locale contains a territory and a dialect, this locale contains an implicit fallback. * - * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope) + * @VueI18nSee [Scope and Locale Changing](../../guide/essentials/scope) * * @defaultValue `'en-US'` */ @@ -151,7 +151,7 @@ export interface VueI18nOptions< * * For more complex fallback definitions see fallback. * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) * * @defaultValue The default `'en-US'` for the `locale` if it's not specified, or it's `locale` value */ @@ -160,7 +160,7 @@ export interface VueI18nOptions< * @remarks * The locale messages of localization. * - * @VueI18nSee [Getting Started](../guide/essentials/started) + * @VueI18nSee [Getting Started](../../guide/essentials/started) * * @defaultValue `{}` */ @@ -176,7 +176,7 @@ export interface VueI18nOptions< * @remarks * The datetime formats of localization. * - * @VueI18nSee [Datetime Formatting](../guide/essentials/datetime) + * @VueI18nSee [Datetime Formatting](../../guide/essentials/datetime) * * @defaultValue `{}` */ @@ -185,7 +185,7 @@ export interface VueI18nOptions< * @remarks * The number formats of localization. * - * @VueI18nSee [Number Formatting](../guide/essentials/number) + * @VueI18nSee [Number Formatting](../../guide/essentials/number) * * @defaultValue `{}` */ @@ -201,7 +201,7 @@ export interface VueI18nOptions< * @remarks * Custom Modifiers for linked messages. * - * @VueI18nSee [Custom Modifiers](../guide/essentials/syntax#custom-modifiers) + * @VueI18nSee [Custom Modifiers](../../guide/essentials/syntax#custom-modifiers) */ modifiers?: Options['modifiers'] /** @@ -221,7 +221,7 @@ export interface VueI18nOptions< * * If `false`, it's not fallback to root. * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) * * @defaultValue `true` */ @@ -234,7 +234,7 @@ export interface VueI18nOptions< * * If you use regular expression, you can suppress localization fail warnings that it match with translation key (e.g. `t`). * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) * * @defaultValue `false` */ @@ -245,7 +245,7 @@ export interface VueI18nOptions< * * If `true`, skip writing templates for your "base" language; the keys are your templates. * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) * * @defaultValue `false` */ @@ -254,7 +254,7 @@ export interface VueI18nOptions< * @remarks * Whether suppress warnings when falling back to either `fallbackLocale` or root. * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) * * @defaultValue `false` */ @@ -265,8 +265,8 @@ export interface VueI18nOptions< * * See the warnHtmlInMessage property. * - * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message) - * @VueI18nSee [Change `warnHtmlInMessage` option default value](../guide/migration/breaking#change-warnhtmlinmessage-option-default-value) + * @VueI18nSee [HTML Message](../../guide/essentials/syntax#html-message) + * @VueI18nSee [Change `warnHtmlInMessage` option default value](../../guide/migration/breaking#change-warnhtmlinmessage-option-default-value) * * @defaultValue `'off'` */ @@ -283,7 +283,7 @@ export interface VueI18nOptions< * * Setting `escapeParameterHtml` as true should not break existing functionality but provides a safeguard against a subtle type of XSS attack vectors. * - * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message) + * @VueI18nSee [HTML Message](../../guide/essentials/syntax#html-message) * * @defaultValue `false` */ @@ -292,7 +292,7 @@ export interface VueI18nOptions< * @remarks * The shared locale messages of localization for components. More detail see Component based localization. * - * @VueI18nSee [Shared locale messages for components](../guide/essentials/local#shared-locale-messages-for-components) + * @VueI18nSee [Shared locale messages for components](../../guide/essentials/local#shared-locale-messages-for-components) * * @defaultValue `undefined` */ @@ -301,7 +301,7 @@ export interface VueI18nOptions< * @remarks * A set of rules for word pluralization * - * @VueI18nSee [Custom Pluralization](../guide/essentials/pluralization#custom-pluralization) + * @VueI18nSee [Custom Pluralization](../../guide/essentials/pluralization#custom-pluralization) * * @defaultValue `{}` */ @@ -321,7 +321,7 @@ export interface VueI18nOptions< * * If `false`, regardless of the root level locale, localize for each component locale. * - * @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-2) + * @VueI18nSee [Local Scope](../../guide/essentials/scope#local-scope-2) * * @defaultValue `true` */ @@ -382,7 +382,7 @@ export interface VueI18nOptions< * @VueI18nWarning * If you use the message resolver, the [`flatJson`](legacy#flatjson) setting will be ignored. That is, you need to resolve the flat JSON by yourself. * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) * * @defaultValue `undefined` */ @@ -441,7 +441,7 @@ export interface VueI18nTranslation< * * @returns Translated message * - * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope) + * @VueI18nSee [Scope and Locale Changing](../../guide/essentials/scope) */ (key: Key | ResourceKeys): TranslateResult /** @@ -459,7 +459,7 @@ export interface VueI18nTranslation< * * @returns Translated message * - * @VueI18nSee [Pluralization](../guide/essentials/pluralization) + * @VueI18nSee [Pluralization](../../guide/essentials/pluralization) */ (key: Key | ResourceKeys, plural: number): TranslateResult /** @@ -480,7 +480,7 @@ export interface VueI18nTranslation< * * @returns Translated message * - * @VueI18nSee [Pluralization](../guide/essentials/pluralization) + * @VueI18nSee [Pluralization](../../guide/essentials/pluralization) */ ( key: Key | ResourceKeys, @@ -540,7 +540,7 @@ export interface VueI18nTranslation< * * @returns Translated message * - * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation) + * @VueI18nSee [List interpolation](../../guide/essentials/syntax#list-interpolation) */ ( key: Key | ResourceKeys, @@ -560,8 +560,8 @@ export interface VueI18nTranslation< * * @returns Translated message * - * @VueI18nSee [Pluralization](../guide/essentials/pluralization) - * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation) + * @VueI18nSee [Pluralization](../../guide/essentials/pluralization) + * @VueI18nSee [List interpolation](../../guide/essentials/syntax#list-interpolation) */ ( key: Key | ResourceKeys, @@ -582,7 +582,7 @@ export interface VueI18nTranslation< * * @returns Translated message * - * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation) + * @VueI18nSee [List interpolation](../../guide/essentials/syntax#list-interpolation) */ ( key: Key | ResourceKeys, @@ -607,7 +607,7 @@ export interface VueI18nTranslation< * * @returns Translated message * - * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation) + * @VueI18nSee [List interpolation](../../guide/essentials/syntax#list-interpolation) */ ( key: Key | ResourceKeys, @@ -625,7 +625,7 @@ export interface VueI18nTranslation< * * @returns Translated message * - * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation) + * @VueI18nSee [Named interpolation](../../guide/essentials/syntax#named-interpolation) */ ( key: Key | ResourceKeys, @@ -645,8 +645,8 @@ export interface VueI18nTranslation< * * @returns Translated message * - * @VueI18nSee [Pluralization](../guide/essentials/pluralization) - * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation) + * @VueI18nSee [Pluralization](../../guide/essentials/pluralization) + * @VueI18nSee [Named interpolation](../../guide/essentials/syntax#named-interpolation) */ ( key: Key | ResourceKeys, @@ -667,7 +667,7 @@ export interface VueI18nTranslation< * * @returns Translated message * - * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation) + * @VueI18nSee [Named interpolation](../../guide/essentials/syntax#named-interpolation) */ ( key: Key | ResourceKeys, @@ -692,7 +692,7 @@ export interface VueI18nTranslation< * * @returns Translated message * - * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation) + * @VueI18nSee [Named interpolation](../../guide/essentials/syntax#named-interpolation) */ ( key: Key | ResourceKeys, @@ -759,7 +759,7 @@ export interface VueI18nDateTimeFormatting< * * @returns Formatted value * - * @VueI18nSee [Datetime formatting](../guide/essentials/datetime) + * @VueI18nSee [Datetime formatting](../../guide/essentials/datetime) */ (value: number | Date): DateTimeFormatResult /** @@ -856,7 +856,7 @@ export interface VueI18nNumberFormatting< * * @returns Formatted value * - * @VueI18nSee [Number formatting](../guide/essentials/number) + * @VueI18nSee [Number formatting](../../guide/essentials/number) */ (value: number): NumberFormatResult /** @@ -952,7 +952,7 @@ export interface VueI18n< * * If the locale contains a territory and a dialect, this locale contains an implicit fallback. * - * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope) + * @VueI18nSee [Scope and Locale Changing](../../guide/essentials/scope) */ // locale: Locales locale: Locales @@ -960,7 +960,7 @@ export interface VueI18n< * @remarks * The current fallback locales this VueI18n instance is using. * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) */ fallbackLocale: FallbackLocales /** @@ -972,28 +972,28 @@ export interface VueI18n< * @remarks * The locale messages of localization. * - * @VueI18nSee [Getting Started](../guide/essentials/started) + * @VueI18nSee [Getting Started](../../guide/essentials/started) */ readonly messages: { [K in keyof Messages]: Messages[K] } /** * @remarks * The datetime formats of localization. * - * @VueI18nSee [Datetime Formatting](../guide/essentials/datetime) + * @VueI18nSee [Datetime Formatting](../../guide/essentials/datetime) */ readonly datetimeFormats: { [K in keyof DateTimeFormats]: DateTimeFormats[K] } /** * @remarks * The number formats of localization. * - * @VueI18nSee [Number Formatting](../guide/essentials/number) + * @VueI18nSee [Number Formatting](../../guide/essentials/number) */ readonly numberFormats: { [K in keyof NumberFormats]: NumberFormats[K] } /** * @remarks * Custom Modifiers for linked messages. * - * @VueI18nSee [Custom Modifiers](../guide/essentials/syntax#custom-modifiers) + * @VueI18nSee [Custom Modifiers](../../guide/essentials/syntax#custom-modifiers) */ readonly modifiers: Composition['modifiers'] /** @@ -1010,7 +1010,7 @@ export interface VueI18n< * @remarks * Whether suppress warnings outputted when localization fails. * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) */ silentTranslationWarn: Composition['missingWarn'] /** @@ -1022,14 +1022,14 @@ export interface VueI18n< * @remarks * Whether suppress warnings when falling back to either `fallbackLocale` or root. * - * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * @VueI18nSee [Fallbacking](../../guide/essentials/fallback) */ formatFallbackMessages: Composition['fallbackFormat'] /** * @remarks * Whether synchronize the root level locale to the component localization locale. * - * @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-2) + * @VueI18nSee [Local Scope](../../guide/essentials/scope#local-scope-2) */ sync: Composition['inheritLocale'] /** @@ -1042,21 +1042,21 @@ export interface VueI18n< * * If you are specified `error` will occurred an Error. * - * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message) - * @VueI18nSee [Change `warnHtmlInMessage` option default value](../guide/migration/breaking#change-warnhtmlinmessage-option-default-value) + * @VueI18nSee [HTML Message](../../guide/essentials/syntax#html-message) + * @VueI18nSee [Change `warnHtmlInMessage` option default value](../../guide/migration/breaking#change-warnhtmlinmessage-option-default-value) */ warnHtmlInMessage: WarnHtmlInMessageLevel /** * @remarks * Whether interpolation parameters are escaped before the message is translated. * - * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message) + * @VueI18nSee [HTML Message](../../guide/essentials/syntax#html-message) */ escapeParameterHtml: Composition['escapeParameter'] /** * A set of rules for word pluralization * - * @VueI18nSee [Custom Pluralization](../guide/essentials/pluralization#custom-pluralization) + * @VueI18nSee [Custom Pluralization](../../guide/essentials/pluralization#custom-pluralization) */ pluralizationRules: Composition['pluralRules'] /** @@ -1111,7 +1111,7 @@ export interface VueI18n< * * If you change the `locale`, the locale messages returned will also correspond to the locale. * - * If there are no locale messages for the given `key` in the composer instance messages, they will be returned with [fallbacking](../guide/essentials/fallback). + * If there are no locale messages for the given `key` in the composer instance messages, they will be returned with [fallbacking](../../guide/essentials/fallback). * * @VueI18nWarning * You need to use `rt` for the locale message returned by `tm`. see the [rt](legacy#rt-message) details.