diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 83a0bcdb7..76b7fd8f6 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vitepress' import type { HeadConfig } from 'vitepress' +import { defineConfig } from 'vitepress' const head: HeadConfig[] = [['link', { rel: 'icon', href: '/vue-i18n-logo.png' }]] @@ -206,6 +206,10 @@ function sidebarGuide() { text: 'Breaking Changes in v10', link: '/guide/migration/breaking10' }, + { + text: 'Breaking Changes in v11', + link: '/guide/migration/breaking11' + }, { text: 'New Features in v9', link: '/guide/migration/features' diff --git a/docs/api/injection.md b/docs/api/injection.md index ab635b537..5229a230b 100644 --- a/docs/api/injection.md +++ b/docs/api/injection.md @@ -597,263 +597,6 @@ Overloaded `$rt`. About details, see the [$rt](injection#rt-message) remarks. Translation message -### $tc(key) - -:::danger NOTICE -**`$tc` has been deprecated in v10. Use `$t` instead. `$tc` is going to remove in v11.** -::: - -Locale message pluralization - -**Signature:** -```typescript -$tc(key: Key): TranslateResult; -``` - -:::warning NOTE -Supported for **Legacy API mode only**. -::: - -**Details** - -If this is used in a reactive context, it will re-evaluate once the locale changes. - -The input / output is the same as for VueI18n instance. About that details, see [VueI18n#tc](legacy#tc-key). - -The value of plural is handled with default `1`. - -**See Also** -- [Pluralization](../guide/essentials/pluralization) - -#### Parameters -| Parameter | Type | Description | -| --- | --- | --- | -| key | Key | A target locale message key | - -#### Returns - -Translation message that is pluraled - -### $tc(key, locale) - -:::danger NOTICE -**`$tc` has been deprecated in v10. Use `$t` instead. `$tc` is going to remove in v11.** -::: - -Locale message pluralization - -**Signature:** -```typescript -$tc(key: Key, locale: Locale): TranslateResult; -``` - -:::warning NOTE -Supported for **Legacy API mode only**. -::: - -**Details** - -Overloaded `$tc`. About details, see the [$tc](injection#tc-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 that is pluraled - -### $tc(key, list) - -:::danger NOTICE -**`$tc` has been deprecated in v10. Use `$t` instead. `$tc` is going to remove in v11.** -::: - -Locale message pluralization - -**Signature:** -```typescript -$tc(key: Key, list: unknown[]): TranslateResult; -``` - -:::warning NOTE -Supported for **Legacy API mode only**. -::: - -**Details** - -Overloaded `$tc`. About details, see the [$tc](injection#tc-key) remarks. - -#### Parameters -| Parameter | Type | Description | -| --- | --- | --- | -| key | Key | A target locale message key | -| list | unknown[] | A values of list interpolation | - -#### Returns - -Translation message that is pluraled - -### $tc(key, named) - -:::danger NOTICE -**`$tc` has been deprecated in v10. Use `$t` instead. `$tc` is going to remove in v11.** -::: - -Locale message pluralization - -**Signature:** -```typescript -$tc(key: Key, named: Record): TranslateResult; -``` - -:::warning NOTE -Supported for **Legacy API mode only**. -::: - -**Details** - -Overloaded `$tc`. About details, see the [$tc](injection#tc-key) remarks. - -#### Parameters -| Parameter | Type | Description | -| --- | --- | --- | -| key | Key | A target locale message key | -| named | Record<string, unknown> | A values of named interpolation | - -#### Returns - -Translation message that is pluraled - -### $tc(key, choice) - -:::danger NOTICE -**`$tc` has been deprecated in v10. Use `$t` instead. `$tc` is going to remove in v11.** -::: - -Locale message pluralization - -**Signature:** -```typescript -$tc(key: Key, choice: number): TranslateResult; -``` - -:::warning NOTE -Supported for **Legacy API mode only**. -::: - -**Details** - -Overloaded `$tc`. About details, see the [$tc](injection#tc-key) remarks. - -#### Parameters -| Parameter | Type | Description | -| --- | --- | --- | -| key | Key | A target locale message key | -| choice | number | Which plural string to get. 1 returns the first one | - -#### Returns - -Translation message that is pluraled - -### $tc(key, choice, locale) - -:::danger NOTICE -**`$tc` has been deprecated in v10. Use `$t` instead. `$tc` is going to remove in v11.** -::: - -Locale message pluralization - -**Signature:** -```typescript -$tc(key: Key, choice: number, locale: Locale): TranslateResult; -``` - -:::warning NOTE -Supported for **Legacy API mode only**. -::: - -**Details** - -Overloaded `$tc`. About details, see the [$tc](injection#tc-key) remarks. - -#### Parameters -| Parameter | Type | Description | -| --- | --- | --- | -| key | Key | A target locale message key | -| choice | number | Which plural string to get. 1 returns the first one | -| locale | Locale | A locale, override locale that global scope or local scope | - -#### Returns - -Translation message that is pluraled - -### $tc(key, choice, list) - -:::danger NOTICE -**`$tc` has been deprecated in v10. Use `$t` instead. `$tc` is going to remove in v11.** -::: - -Locale message pluralization - -**Signature:** -```typescript -$tc(key: Key, choice: number, list: unknown[]): TranslateResult; -``` - -:::warning NOTE -Supported for **Legacy API mode only**. -::: - -**Details** - -Overloaded `$tc`. About details, see the [$tc](injection#tc-key) remarks. - -#### Parameters -| Parameter | Type | Description | -| --- | --- | --- | -| key | Key | A target locale message key | -| choice | number | Which plural string to get. 1 returns the first one | -| list | unknown[] | A values of list interpolation | - -#### Returns - -Translation message that is pluraled - -### $tc(key, choice, named) - -:::danger NOTICE -**`$tc` has been deprecated in v10. Use `$t` instead. `$tc` is going to remove in v11.** -::: - -Locale message pluralization - -**Signature:** -```typescript -$tc(key: Key, choice: number, named: Record): TranslateResult; -``` - -:::warning NOTE -Supported for **Legacy API mode only**. -::: - -**Details** - -Overloaded `$tc`. About details, see the [$tc](injection#tc-key) remarks. - -#### Parameters -| Parameter | Type | Description | -| --- | --- | --- | -| key | Key | A target locale message key | -| choice | number | Which plural string to get. 1 returns the first one | -| named | Record<string, unknown> | A values of named interpolation | - -#### Returns - -Translation message that is pluraled - ### $te(key, locale) Translation message exist diff --git a/docs/guide/advanced/composition.md b/docs/guide/advanced/composition.md index 981b9c589..ed8272151 100644 --- a/docs/guide/advanced/composition.md +++ b/docs/guide/advanced/composition.md @@ -137,8 +137,6 @@ For more details of `t`, see the [API Reference](../../api/composition#t-key). ## Pluralization -In the Legacy API mode, the plural form of the message was translated using either `$tc` or the VueI18n instance of `tc` to translate the message. - In the Composition API mode, the plural form of the message is left in syntax as in the Legacy API mode, but is translated using the `t` of the Composer instance: ```vue diff --git a/docs/guide/essentials/local.md b/docs/guide/essentials/local.md index e58e326f9..160c8da7d 100644 --- a/docs/guide/essentials/local.md +++ b/docs/guide/essentials/local.md @@ -4,7 +4,7 @@ [In *'Scope and Locale Changing’*](scope), Vue I18n has two scope concepts, global scope and local scope. -In general, locale info (e.g. `locale`,`messages`, etc) is set as option of `createI18n` and it sets (install) with `app.use`. To sum up, you use global scope translation functions `$t` and `$tc` to localize them. +In general, locale info (e.g. `locale`,`messages`, etc) is set as option of `createI18n` and it sets (install) with `app.use`. To sum up, you use global scope translation functions `$t` to localize them. Sometimes it is necessary to localize per component while still managing the resources of the local messages. In this case it can be useful to localize each local scope using i18n component option on the component instead of the global scope. diff --git a/docs/guide/essentials/pluralization.md b/docs/guide/essentials/pluralization.md index cc7c2d898..a58148720 100644 --- a/docs/guide/essentials/pluralization.md +++ b/docs/guide/essentials/pluralization.md @@ -87,7 +87,7 @@ The `apple` has `no apples | one apple | {count} apples` pluralization message, The number can be accessed within locale messages via predefined named arguments `{count}` and/or `{n}`. You can overwrite those predefined named arguments if necessary. -The following is an example of using `$tc`: +The following is an example of using `$t`: ```html

{{ $t('apple', 10, { count: 10 }) }}

diff --git a/docs/guide/migration/breaking11.md b/docs/guide/migration/breaking11.md new file mode 100644 index 000000000..5400020b0 --- /dev/null +++ b/docs/guide/migration/breaking11.md @@ -0,0 +1,18 @@ +# Breaking Changes in v11 + +## Deprecate Legacy API mode + +### Reason + +The Legacy API mode was the API mode compatible with v8 for Vue 2. When v9 was released, the Legacy API was provided to smooth the migration from v8 to v9. + +Legacy API mode will be deprecated in v11, as previous vue-i18n releases have already provided the following to support migration to Composition API mode + +- Migration from Legacy API mode to Composition API mode: https://vue-i18n.intlify.dev/guide/migration/vue3.html +- Composition API usage: https://vue-i18n.intlify.dev/guide/advanced/composition.html + +For compatibility, Legacy API mode still works in v11, but will be removed entirely in v12, so Legacy API mode will not work after that version. + +## Drop `tc` and `$tc` for Legacy API mode + +**Reason**: These APIs had already deprecated in warning about being dropped in v11. docs says, https://vue-i18n.intlify.dev/guide/migration/breaking10.html#deprecate-tc-and-tc-for-legacy-api-mode diff --git a/packages/petite-vue-i18n/src/index.ts b/packages/petite-vue-i18n/src/index.ts index 9748c1296..9f3895960 100644 --- a/packages/petite-vue-i18n/src/index.ts +++ b/packages/petite-vue-i18n/src/index.ts @@ -93,7 +93,6 @@ export { VueI18nOptions, VueI18nResolveLocaleMessageTranslation, VueI18nTranslation, - VueI18nTranslationChoice, WarnHtmlInMessageLevel } from '../../vue-i18n-core/src/legacy' export { I18nPluginOptions } from '../../vue-i18n-core/src/plugin' diff --git a/packages/petite-vue-i18n/src/runtime.ts b/packages/petite-vue-i18n/src/runtime.ts index 25d672017..a2898353f 100644 --- a/packages/petite-vue-i18n/src/runtime.ts +++ b/packages/petite-vue-i18n/src/runtime.ts @@ -92,7 +92,6 @@ export { VueI18nOptions, VueI18nResolveLocaleMessageTranslation, VueI18nTranslation, - VueI18nTranslationChoice, WarnHtmlInMessageLevel } from '../../vue-i18n-core/src/legacy' export { I18nPluginOptions } from '../../vue-i18n-core/src/plugin' diff --git a/packages/vue-i18n-core/src/index.ts b/packages/vue-i18n-core/src/index.ts index 0e194ca79..65f3c72d2 100644 --- a/packages/vue-i18n-core/src/index.ts +++ b/packages/vue-i18n-core/src/index.ts @@ -1,120 +1,119 @@ -import { getGlobalThis } from '@intlify/shared' import { setDevToolsHook } from '@intlify/core-base' +import { getGlobalThis } from '@intlify/shared' import { initDev, initFeatureFlags } from './misc' export { - SchemaParams, - LocaleParams, - Path, - PathValue, - NamedValue, - Locale, + CompileError, + DateTimeOptions, FallbackLocale, - LocaleMessageValue, - LocaleMessageDictionary, - LocaleMessageType, - LocaleMessages, - LocaleMessage, - NumberFormat as IntlNumberFormat, DateTimeFormat as IntlDateTimeFormat, DateTimeFormats as IntlDateTimeFormats, - NumberFormats as IntlNumberFormats, - LocaleMatcher as IntlLocaleMatcher, FormatMatcher as IntlFormatMatcher, - MessageFunction, - MessageFunctions, - PluralizationRule, + LocaleMatcher as IntlLocaleMatcher, + NumberFormat as IntlNumberFormat, + NumberFormats as IntlNumberFormats, LinkedModifiers, - TranslateOptions, - DateTimeOptions, - NumberOptions, - PostTranslationHandler, - MessageResolver, + Locale, + LocaleMessage, + LocaleMessageDictionary, + LocaleMessages, + LocaleMessageType, + LocaleMessageValue, + LocaleParams, MessageCompiler, MessageCompilerContext, - CompileError, MessageContext, - RemovedIndexResources + MessageFunction, + MessageFunctions, + MessageResolver, + NamedValue, + NumberOptions, + Path, + PathValue, + PluralizationRule, + PostTranslationHandler, + RemovedIndexResources, + SchemaParams, + TranslateOptions } from '@intlify/core-base' export { - VueMessageType, - DefineLocaleMessage, - DefaultLocaleMessageSchema, - DefineDateTimeFormat, - DefaultDateTimeFormatSchema, - DefineNumberFormat, - DefaultNumberFormatSchema, - MissingHandler, - ComposerOptions, + BaseFormatProps, + ComponentI18nScope, + DatetimeFormat, + DatetimeFormatProps, + FormattableProps, + I18nD, + I18nN, + I18nT, + NumberFormat, + NumberFormatProps, + Translation, + TranslationProps +} from './components' +export { Composer, ComposerCustom, - CustomBlock, - CustomBlocks, - ComposerTranslation, ComposerDateTimeFormatting, ComposerNumberFormatting, - ComposerResolveLocaleMessageTranslation + ComposerOptions, + ComposerResolveLocaleMessageTranslation, + ComposerTranslation, + CustomBlock, + CustomBlocks, + DefaultDateTimeFormatSchema, + DefaultLocaleMessageSchema, + DefaultNumberFormatSchema, + DefineDateTimeFormat, + DefineLocaleMessage, + DefineNumberFormat, + MissingHandler, + VueMessageType } from './composer' export { - TranslateResult, + TranslationDirective, + vTDirective, + VTDirectiveValue +} from './directive' +export { + ComposerAdditionalOptions, + ComposerExtender, + createI18n, + ExportedGlobalComposer, + I18n, + I18nAdditionalOptions, + I18nInjectionKey, + I18nMode, + I18nOptions, + I18nScope, + useI18n, + UseI18nOptions +} from './i18n' +export { Choice, - LocaleMessageObject, - PluralizationRulesMap, - WarnHtmlInMessageLevel, DateTimeFormatResult, + LocaleMessageObject, NumberFormatResult, - VueI18nOptions, + PluralizationRulesMap, + TranslateResult, VueI18n, - VueI18nTranslation, - VueI18nTranslationChoice, VueI18nDateTimeFormatting, + VueI18nExtender, VueI18nNumberFormatting, + VueI18nOptions, VueI18nResolveLocaleMessageTranslation, - VueI18nExtender + VueI18nTranslation, + WarnHtmlInMessageLevel } from './legacy' -export { - createI18n, - useI18n, - I18nInjectionKey, - I18nOptions, - I18nAdditionalOptions, - I18n, - I18nMode, - I18nScope, - ComposerAdditionalOptions, - UseI18nOptions, - ExportedGlobalComposer, - ComposerExtender -} from './i18n' -export { - Translation, - I18nT, - NumberFormat, - I18nN, - DatetimeFormat, - I18nD, - TranslationProps, - NumberFormatProps, - DatetimeFormatProps, - FormattableProps, - BaseFormatProps, - ComponentI18nScope -} from './components' -export { - vTDirective, - VTDirectiveValue, - TranslationDirective -} from './directive' -export { I18nPluginOptions } from './plugin' export { VERSION } from './misc' +export { I18nPluginOptions } from './plugin' export { Disposer } from './types' export type { - IsNever, IsEmptyObject, - PickupPaths, + IsNever, + PickupFormatPathKeys, PickupKeys, - PickupFormatPathKeys + PickupPaths } from '@intlify/core-base' if (__ESM_BUNDLER__ && !__TEST__) { diff --git a/packages/vue-i18n-core/src/legacy.ts b/packages/vue-i18n-core/src/legacy.ts index d713d8d84..9d5dace6b 100644 --- a/packages/vue-i18n-core/src/legacy.ts +++ b/packages/vue-i18n-core/src/legacy.ts @@ -5,16 +5,12 @@ import { isArray, isBoolean, isFunction, - isNumber, isPlainObject, isRegExp, - isString, - warnOnce + isString } from '@intlify/shared' import { createComposer, DefineLocaleMessage } from './composer' -import { createI18nError, I18nErrorCodes } from './errors' import { DisableEmitter, EnableEmitter } from './symbols' -import { getWarnMessage, I18nWarnCodes } from './warnings' import type { DateTimeFormat, @@ -312,7 +308,7 @@ export interface VueI18nOptions< pluralizationRules?: Options['pluralRules'] /** * @remarks - * A handler for post processing of translation. The handler gets after being called with the `$t`, `t`, `$tc`, and `tc`. + * 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. * @@ -348,8 +344,6 @@ export interface VueI18nOptions< * * - [`t`](legacy#t-key) * - * - [`tc`](legacy#tc-key) - * * - [`te`](legacy#te-key-locale) * * - [`tm`](legacy#tm-key) @@ -720,164 +714,6 @@ export interface VueI18nTranslation< export type VueI18nResolveLocaleMessageTranslation = ComposerResolveLocaleMessageTranslation -/** - * Locale message pluralization functions for VueI18n legacy interfaces - * - * @remarks - * This is the interface for {@link VueI18n} - * - * @deprecated will be removed at vue-i18n v12 - * - * @VueI18nLegacy - */ -export interface VueI18nTranslationChoice< - Messages extends Record = {}, - 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 -> { - /** - * Locale message pluralization - * - * @remarks - * 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 pluraled in preferentially local scope locale messages than global scope locale messages. - * - * If [i18n component options](injection#i18n) isn't specified, it’s pluraled with global scope locale messages. - * - * The plural choice number is handled with default `1`. - * - * @param key - A target locale message key - * - * @returns Pluraled message - * - * @VueI18nSee [Pluralization](../guide/essentials/pluralization) - */ - (key: Key | ResourceKeys): TranslateResult - /** - * Locale message pluralization - * - * @remarks - * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details. - * - * @param key - A target locale message key - * @param locale - A locale, it will be used over than global scope or local scope. - * - * @returns Pluraled message - */ - ( - key: Key | ResourceKeys, - locale: Locales | Locale - ): TranslateResult - /** - * Locale message pluralization - * - * @remarks - * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details. - * - * @param key - A target locale message key - * @param list - A values of list interpolation - * - * @returns Pluraled message - */ - ( - key: Key | ResourceKeys, - list: unknown[] - ): TranslateResult - /** - * Locale message pluralization - * - * @remarks - * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details. - * - * @param key - A target locale message key - * @param named - A values of named interpolation - * - * @returns Pluraled message - */ - ( - key: Key | ResourceKeys, - named: Record - ): TranslateResult - /** - * Locale message pluralization - * - * @remarks - * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details. - * - * @param key - A target locale message key - * @param choice - Which plural string to get. 1 returns the first one. - * - * @returns Pluraled message - */ - (key: Key | ResourceKeys, choice: number): TranslateResult - /** - * Locale message pluralization - * - * @remarks - * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details. - * - * @param key - A target locale message key - * @param choice - Which plural string to get. 1 returns the first one. - * @param locale - A locale, it will be used over than global scope or local scope. - * - * @returns Pluraled message - */ - ( - key: Key | ResourceKeys, - choice: number, - locale: Locales | Locale - ): TranslateResult - /** - * Locale message pluralization - * - * @remarks - * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details. - * - * @param key - A target locale message key - * @param choice - Which plural string to get. 1 returns the first one. - * @param list - A values of list interpolation - * - * @returns Pluraled message - */ - ( - key: Key | ResourceKeys, - choice: number, - list: unknown[] - ): TranslateResult - /** - * Locale message pluralization - * - * @remarks - * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details. - * - * @param key - A target locale message key - * @param choice - Which plural string to get. 1 returns the first one. - * @param named - A values of named interpolation - * - * @returns Pluraled message - */ - ( - key: Key | ResourceKeys, - choice: number, - named: Record - ): TranslateResult -} - /** * Datetime formatting functions for VueI18n legacy interfaces * @@ -1243,19 +1079,6 @@ export interface VueI18n< * About details functions, See the {@link VueI18nResolveLocaleMessageTranslation} */ rt: VueI18nResolveLocaleMessageTranslation - /** - * Locale message pluralization - * - * @remarks - * About details functions, See the {@link VueI18nTranslationChoice} - */ - tc: VueI18nTranslationChoice< - Messages, - Locales, - RemoveIndexSignature<{ - [K in keyof DefineLocaleMessage]: DefineLocaleMessage[K] - }> - > /** * Translation locale message exist * @@ -1756,48 +1579,6 @@ export function createVueI18n(options: any = {}): any { return Reflect.apply(composer.rt, composer, [...args]) }, - // tc - tc(...args: unknown[]): TranslateResult { - const [arg1, arg2, arg3] = args - const options = { plural: 1 } as TranslateOptions - let list: unknown[] | null = null - let named: NamedValue | null = null - - if (__DEV__) { - warnOnce(getWarnMessage(I18nWarnCodes.DEPRECATE_TC)) - } - - if (!isString(arg1)) { - throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT) - } - const key = arg1 - - if (isString(arg2)) { - options.locale = arg2 - } else if (isNumber(arg2)) { - options.plural = arg2 - } else if (isArray(arg2)) { - list = arg2 - } else if (isPlainObject(arg2)) { - named = arg2 as NamedValue - } - - if (isString(arg3)) { - options.locale = arg3 - } else if (isArray(arg3)) { - list = arg3 - } else if (isPlainObject(arg3)) { - named = arg3 as NamedValue - } - - // return composer.t(key, (list || named || {}) as any, options) - return Reflect.apply(composer.t, composer, [ - key, - (list || named || {}) as any, - options - ]) - }, - // te te(key: Path, locale?: Locale): boolean { return composer.te(key, locale) diff --git a/packages/vue-i18n-core/src/mixins.ts b/packages/vue-i18n-core/src/mixins.ts index 5f36180ed..6794aca8c 100644 --- a/packages/vue-i18n-core/src/mixins.ts +++ b/packages/vue-i18n-core/src/mixins.ts @@ -101,7 +101,6 @@ export function defineMixin( // defines vue-i18n legacy APIs this.$t = (...args: unknown[]): TranslateResult => this.$i18n.t(...args) this.$rt = (...args: unknown[]): TranslateResult => this.$i18n.rt(...args) - this.$tc = (...args: unknown[]): TranslateResult => this.$i18n.tc(...args) this.$te = (key: Path, locale?: Locale): boolean => this.$i18n.te(key, locale) this.$d = (...args: unknown[]): DateTimeFormatResult => @@ -159,7 +158,6 @@ export function defineMixin( delete this.$t delete this.$rt - delete this.$tc delete this.$te delete this.$d delete this.$n diff --git a/packages/vue-i18n-core/src/warnings.ts b/packages/vue-i18n-core/src/warnings.ts index 1a52244db..70388d4d1 100644 --- a/packages/vue-i18n-core/src/warnings.ts +++ b/packages/vue-i18n-core/src/warnings.ts @@ -5,11 +5,10 @@ export const I18nWarnCodes = { FALLBACK_TO_ROOT: CORE_WARN_CODES_EXTEND_POINT, // 8 NOT_FOUND_PARENT_SCOPE: 9, IGNORE_OBJ_FLATTEN: 10, - DEPRECATE_TC: 11, /** * @deprecated will be removed at vue-i18n v12 */ - DEPRECATE_LEGACY_MODE: 12 + DEPRECATE_LEGACY_MODE: 11 } as const type I18nWarnCodes = (typeof I18nWarnCodes)[keyof typeof I18nWarnCodes] @@ -18,7 +17,6 @@ export const warnMessages: { [code: number]: string } = { [I18nWarnCodes.FALLBACK_TO_ROOT]: `Fall back to {type} '{key}' with root locale.`, [I18nWarnCodes.NOT_FOUND_PARENT_SCOPE]: `Not found parent scope. use the global scope.`, [I18nWarnCodes.IGNORE_OBJ_FLATTEN]: `Ignore object flatten: '{key}' key has an string value`, - [I18nWarnCodes.DEPRECATE_TC]: `'tc' and '$tc' has been deprecated in v10. Use 't' or '$t' instead. 'tc' and '$tc’ are going to remove in v11.`, /** * @deprecated will be removed at vue-i18n v12 */ diff --git a/packages/vue-i18n-core/test/i18n.test-d.ts b/packages/vue-i18n-core/test/i18n.test-d.ts index 78facc5c4..fc3d7d62a 100644 --- a/packages/vue-i18n-core/test/i18n.test-d.ts +++ b/packages/vue-i18n-core/test/i18n.test-d.ts @@ -385,15 +385,6 @@ test('loose i18n', () => { expectTypeOf(looseI18n.t('nest', 'en')).toEqualTypeOf() expectTypeOf(looseI18n.t('foo', [1])).toEqualTypeOf() expectTypeOf(looseI18n.t('nest', { foo: 1 })).toEqualTypeOf() - expectTypeOf(looseI18n.tc('nest')).toEqualTypeOf() - expectTypeOf(looseI18n.tc('bar', 'en')).toEqualTypeOf() - expectTypeOf(looseI18n.tc('bar', ['foo'])).toEqualTypeOf() - expectTypeOf(looseI18n.tc('bar', { foo: 'foo' })).toEqualTypeOf() - expectTypeOf(looseI18n.tc('nest.bar', 1)).toEqualTypeOf() - expectTypeOf(looseI18n.tc('nest.bar', 1, ['bar'])).toEqualTypeOf() - expectTypeOf( - looseI18n.tc('nest.bar', 1, { foo: 'bar' }) - ).toEqualTypeOf() expectTypeOf(looseI18n.te('errors', 'en')).toEqualTypeOf() expectTypeOf(looseI18n.tm('nest')).toEqualTypeOf<{ bar: string }>() expectTypeOf(looseI18n.tm('errors')).toEqualTypeOf< diff --git a/packages/vue-i18n-core/test/i18n.test.ts b/packages/vue-i18n-core/test/i18n.test.ts index 192c97566..0d6ae7488 100644 --- a/packages/vue-i18n-core/test/i18n.test.ts +++ b/packages/vue-i18n-core/test/i18n.test.ts @@ -14,33 +14,33 @@ vi.mock('@intlify/shared', async () => { }) import { - h, - ref, - defineComponent, - defineCustomElement, - nextTick, - getCurrentInstance, - ComponentOptions -} from 'vue' -import { - setDevToolsHook, compile, + fallbackWithLocaleChain, + registerLocaleFallbacker, registerMessageCompiler, - resolveValue, registerMessageResolver, - fallbackWithLocaleChain, - registerLocaleFallbacker + resolveValue, + setDevToolsHook } from '@intlify/core-base' import { createEmitter } from '@intlify/shared' -import { mount, pluralRules as _pluralRules, randStr } from './helper' -import { createI18n, useI18n } from '../src/i18n' -import { errorMessages, I18nErrorCodes } from '../src/errors' +import { + ComponentOptions, + defineComponent, + defineCustomElement, + getCurrentInstance, + h, + nextTick, + ref +} from 'vue' import { Composer } from '../src/composer' +import { errorMessages, I18nErrorCodes } from '../src/errors' +import { createI18n, useI18n } from '../src/i18n' +import { pluralRules as _pluralRules, mount, randStr } from './helper' import type { IntlifyDevToolsEmitterHooks } from '@intlify/devtools-types' +import type { App } from 'vue' import type { I18n } from '../src/i18n' import type { VueI18n } from '../src/legacy' -import type { App } from 'vue' /* eslint-disable @typescript-eslint/no-explicit-any */ // allow any in error const container = document.createElement('div') @@ -1054,11 +1054,11 @@ describe('custom pluralization', () => { const App = defineComponent({ template: ` -

{{ $tc('car', 1) }}

-

{{ $tc('car', 2) }}

-

{{ $tc('car', 4) }}

-

{{ $tc('car', 12) }}

-

{{ $tc('car', 21) }}

+

{{ $t('car', 1) }}

+

{{ $t('car', 2) }}

+

{{ $t('car', 4) }}

+

{{ $t('car', 12) }}

+

{{ $t('car', 21) }}

` }) const { find } = await mount(App, i18n) @@ -1086,11 +1086,11 @@ describe('custom pluralization', () => { } ], template: ` -

{{ $tc('car', 1) }}

-

{{ $tc('car', 2) }}

-

{{ $tc('car', 4) }}

-

{{ $tc('car', 12) }}

-

{{ $tc('car', 21) }}

+

{{ $t('car', 1) }}

+

{{ $t('car', 2) }}

+

{{ $t('car', 4) }}

+

{{ $t('car', 12) }}

+

{{ $t('car', 21) }}

` }) const { find } = await mount(App, i18n) diff --git a/packages/vue-i18n-core/test/legacy.test-d.ts b/packages/vue-i18n-core/test/legacy.test-d.ts index 92af647fd..eacc42e3e 100644 --- a/packages/vue-i18n-core/test/legacy.test-d.ts +++ b/packages/vue-i18n-core/test/legacy.test-d.ts @@ -100,15 +100,6 @@ test('loose legacy', () => { expectTypeOf(looseVueI18n.t('nest', 'en')).toEqualTypeOf() expectTypeOf(looseVueI18n.t('foo', [1])).toEqualTypeOf() expectTypeOf(looseVueI18n.t('nest', { foo: 1 })).toEqualTypeOf() - expectTypeOf(looseVueI18n.tc('nest')).toEqualTypeOf() - expectTypeOf(looseVueI18n.tc('bar', 'en')).toEqualTypeOf() - expectTypeOf(looseVueI18n.tc('bar', ['foo'])).toEqualTypeOf() - expectTypeOf(looseVueI18n.tc('bar', { foo: 'foo' })).toEqualTypeOf() - expectTypeOf(looseVueI18n.tc('nest.bar', 1)).toEqualTypeOf() - expectTypeOf(looseVueI18n.tc('nest.bar', 1, ['bar'])).toEqualTypeOf() - expectTypeOf( - looseVueI18n.tc('nest.bar', 1, { foo: 'bar' }) - ).toEqualTypeOf() expectTypeOf(looseVueI18n.te('errors', 'en')).toEqualTypeOf() expectTypeOf(looseVueI18n.tm('nest')).toEqualTypeOf<{ bar: string }>() expectTypeOf(looseVueI18n.tm('errors')).toEqualTypeOf() @@ -202,15 +193,6 @@ test('strict legacy', () => { expectTypeOf(strictVueI18n.t('nest', 'en')).toEqualTypeOf() expectTypeOf(strictVueI18n.t('foo', [1])).toEqualTypeOf() expectTypeOf(strictVueI18n.t('nest', { foo: 1 })).toEqualTypeOf() - expectTypeOf(strictVueI18n.tc('nest')).toEqualTypeOf() - expectTypeOf(strictVueI18n.tc('bar', 'en')).toEqualTypeOf() - expectTypeOf(strictVueI18n.tc('bar', ['foo'])).toEqualTypeOf() - expectTypeOf(strictVueI18n.tc('bar', { foo: 'foo' })).toEqualTypeOf() - expectTypeOf(strictVueI18n.tc('nest.bar', 1)).toEqualTypeOf() - expectTypeOf(strictVueI18n.tc('nest.bar', 1, ['bar'])).toEqualTypeOf() - expectTypeOf( - strictVueI18n.tc('nest.bar', 1, { foo: 'bar' }) - ).toEqualTypeOf() expectTypeOf(strictVueI18n.te('errors', 'en')).toEqualTypeOf() expectTypeOf(strictVueI18n.tm('nest')).toEqualTypeOf<{ bar: string }>() expectTypeOf(strictVueI18n.tm('errors')).toEqualTypeOf() diff --git a/packages/vue-i18n-core/test/legacy.test.ts b/packages/vue-i18n-core/test/legacy.test.ts index 8efe0cea3..67237042e 100644 --- a/packages/vue-i18n-core/test/legacy.test.ts +++ b/packages/vue-i18n-core/test/legacy.test.ts @@ -11,19 +11,18 @@ vi.mock('@intlify/shared', async () => { } }) -import { VueMessageType } from '../src/composer' -import { createVueI18n } from '../src/legacy' -import { errorMessages, I18nErrorCodes } from '../src/errors' -import { watchEffect, nextTick } from 'vue' import { compile, - registerMessageCompiler, - resolveValue, - registerMessageResolver, MessageContext, Path, - PathValue + PathValue, + registerMessageCompiler, + registerMessageResolver, + resolveValue } from '@intlify/core-base' +import { nextTick, watchEffect } from 'vue' +import { VueMessageType } from '../src/composer' +import { createVueI18n } from '../src/legacy' import { pluralRules as _pluralRules } from './helper' beforeEach(() => { @@ -118,10 +117,6 @@ test('postTranslation', () => { }) test('pluralizationRules', () => { - const mockWarn = vi.spyOn(shared, 'warnOnce') - // eslint-disable-next-line @typescript-eslint/no-empty-function - mockWarn.mockImplementation(() => {}) - const i18n = createVueI18n({ locale: 'ru', pluralizationRules: _pluralRules, @@ -133,13 +128,11 @@ test('pluralizationRules', () => { }) expect(i18n.pluralizationRules).toEqual(_pluralRules) - expect(i18n.tc('car', 1)).toEqual('1 машина') - expect(i18n.tc('car', 2)).toEqual('2 машины') - expect(i18n.tc('car', 4)).toEqual('4 машины') - expect(i18n.tc('car', 12)).toEqual('12 машин') - expect(i18n.tc('car', 21)).toEqual('21 машина') - - expect(mockWarn).toHaveBeenCalled() + expect(i18n.t('car', 1)).toEqual('1 машина') + expect(i18n.t('car', 2)).toEqual('2 машины') + expect(i18n.t('car', 4)).toEqual('4 машины') + expect(i18n.t('car', 12)).toEqual('12 машин') + expect(i18n.t('car', 21)).toEqual('21 машина') }) test('messages', () => { @@ -238,36 +231,6 @@ describe('rt', () => { }) }) -describe('tc', () => { - test('basic', () => { - const i18n = createVueI18n({ - locale: 'en', - messages: { - en: { - apple: 'no apples | one apple | {count} apples' - } - } - }) - - expect(i18n.tc('apple', 4)).toEqual('4 apples') - }) - - test(errorMessages[I18nErrorCodes.INVALID_ARGUMENT], () => { - const i18n = createVueI18n({ - locale: 'en', - messages: { - en: { - apple: 'no apples | one apple | {count} apples' - } - } - }) - - expect(() => { - i18n.tc(4 as any, 4) // eslint-disable-line @typescript-eslint/no-explicit-any - }).toThrowError(errorMessages[I18nErrorCodes.INVALID_ARGUMENT]) - }) -}) - test('te', () => { const i18n = createVueI18n({ locale: 'en', diff --git a/packages/vue-i18n-core/test/mixin.test.ts b/packages/vue-i18n-core/test/mixin.test.ts index 02b8b4c91..ff8915065 100644 --- a/packages/vue-i18n-core/test/mixin.test.ts +++ b/packages/vue-i18n-core/test/mixin.test.ts @@ -3,7 +3,6 @@ */ // utils -import * as shared from '@intlify/shared' vi.mock('@intlify/shared', async () => { const actual = await vi.importActual('@intlify/shared') return { @@ -135,28 +134,6 @@ test('$rt', async () => { expect(html()).toEqual('

Title 1

Title 2

') }) -test('$tc', async () => { - const mockWarn = vi.spyOn(shared, 'warnOnce') - // eslint-disable-next-line @typescript-eslint/no-empty-function - mockWarn.mockImplementation(() => {}) - - const i18n = createI18n({ - legacy: true, - locale: 'en', - messages: { - en: { - banana: 'no bananas | {n} banana | {n} bananas' - } - } - }) - - const App = defineComponent({ template: '
' }) - const { vm } = await mount(App, i18n) - - expect(vm.$tc!('banana', 2)).toEqual('2 bananas') - expect(mockWarn).toHaveBeenCalled() -}) - test('$te', async () => { const i18n = createI18n({ legacy: true, diff --git a/packages/vue-i18n-core/test/warnings.test.ts b/packages/vue-i18n-core/test/warnings.test.ts deleted file mode 100644 index 174f0b64b..000000000 --- a/packages/vue-i18n-core/test/warnings.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { I18nWarnCodes } from '../src/warnings' - -test('I18nWarnCodes', () => { - expect(I18nWarnCodes.DEPRECATE_TC).toBe(11) -}) diff --git a/packages/vue-i18n/src/index.ts b/packages/vue-i18n/src/index.ts index 53c16ee0c..c9b97463c 100644 --- a/packages/vue-i18n/src/index.ts +++ b/packages/vue-i18n/src/index.ts @@ -1,13 +1,13 @@ -import { getGlobalThis } from '@intlify/shared' import { - setDevToolsHook, - registerMessageCompiler, compile, + fallbackWithLocaleChain, + registerLocaleFallbacker, + registerMessageCompiler, registerMessageResolver, resolveValue, - registerLocaleFallbacker, - fallbackWithLocaleChain + setDevToolsHook } from '@intlify/core-base' +import { getGlobalThis } from '@intlify/shared' import { initDev, initFeatureFlags } from '../../vue-i18n-core/src/misc' if (__ESM_BUNDLER__ && !__TEST__) { @@ -24,116 +24,115 @@ registerMessageResolver(resolveValue) registerLocaleFallbacker(fallbackWithLocaleChain) export { - Path, - PathValue, - NamedValue, - Locale, + CompileError, + DateTimeOptions, FallbackLocale, - LocaleMessageValue, - LocaleMessageDictionary, - LocaleMessageType, - LocaleMessages, - NumberFormat as IntlNumberFormat, + GeneratedTypeConfig, DateTimeFormat as IntlDateTimeFormat, DateTimeFormats as IntlDateTimeFormats, - NumberFormats as IntlNumberFormats, - LocaleMatcher as IntlLocaleMatcher, FormatMatcher as IntlFormatMatcher, - MessageFunction, - MessageFunctions, - PluralizationRule, + LocaleMatcher as IntlLocaleMatcher, + NumberFormat as IntlNumberFormat, + NumberFormats as IntlNumberFormats, LinkedModifiers, - TranslateOptions, - DateTimeOptions, - NumberOptions, - PostTranslationHandler, - MessageResolver, + Locale, + LocaleMessageDictionary, + LocaleMessages, + LocaleMessageType, + LocaleMessageValue, MessageCompiler, MessageCompilerContext, - CompileError, MessageContext, + MessageFunction, + MessageFunctions, + MessageResolver, + NamedValue, + NumberOptions, + Path, + PathValue, + PluralizationRule, + PostTranslationHandler, RemovedIndexResources, - GeneratedTypeConfig + TranslateOptions } from '@intlify/core-base' export { - VueMessageType, - DefineLocaleMessage, - DefaultLocaleMessageSchema, - DefineDateTimeFormat, - DefaultDateTimeFormatSchema, - DefineNumberFormat, - DefaultNumberFormatSchema, - MissingHandler, - ComposerOptions, + BaseFormatProps, + ComponentI18nScope, + DatetimeFormat, + DatetimeFormatProps, + FormattableProps, + I18nD, + I18nN, + I18nT, + NumberFormat, + NumberFormatProps, + Translation, + TranslationProps +} from '../../vue-i18n-core/src/components' +export { Composer, ComposerCustom, - CustomBlock, - CustomBlocks, - ComposerTranslation, ComposerDateTimeFormatting, ComposerNumberFormatting, - ComposerResolveLocaleMessageTranslation + ComposerOptions, + ComposerResolveLocaleMessageTranslation, + ComposerTranslation, + CustomBlock, + CustomBlocks, + DefaultDateTimeFormatSchema, + DefaultLocaleMessageSchema, + DefaultNumberFormatSchema, + DefineDateTimeFormat, + DefineLocaleMessage, + DefineNumberFormat, + MissingHandler, + VueMessageType } from '../../vue-i18n-core/src/composer' export { - TranslateResult, + TranslationDirective, + vTDirective, + VTDirectiveValue +} from '../../vue-i18n-core/src/directive' +export { + ComposerAdditionalOptions, + ComposerExtender, + createI18n, + ExportedGlobalComposer, + I18n, + I18nAdditionalOptions, + I18nInjectionKey, + I18nMode, + I18nOptions, + I18nScope, + useI18n, + UseI18nOptions +} from '../../vue-i18n-core/src/i18n' +export { Choice, - LocaleMessageObject, - PluralizationRulesMap, - WarnHtmlInMessageLevel, DateTimeFormatResult, + LocaleMessageObject, NumberFormatResult, - VueI18nOptions, + PluralizationRulesMap, + TranslateResult, VueI18n, - VueI18nTranslation, - VueI18nTranslationChoice, VueI18nDateTimeFormatting, + VueI18nExtender, VueI18nNumberFormatting, + VueI18nOptions, VueI18nResolveLocaleMessageTranslation, - VueI18nExtender + VueI18nTranslation, + WarnHtmlInMessageLevel } from '../../vue-i18n-core/src/legacy' -export { - createI18n, - useI18n, - I18nInjectionKey, - I18nOptions, - I18nAdditionalOptions, - I18n, - I18nMode, - I18nScope, - ComposerAdditionalOptions, - UseI18nOptions, - ExportedGlobalComposer, - ComposerExtender -} from '../../vue-i18n-core/src/i18n' -export { - Translation, - I18nT, - NumberFormat, - I18nN, - DatetimeFormat, - I18nD, - TranslationProps, - NumberFormatProps, - DatetimeFormatProps, - FormattableProps, - BaseFormatProps, - ComponentI18nScope -} from '../../vue-i18n-core/src/components' -export { - vTDirective, - VTDirectiveValue, - TranslationDirective -} from '../../vue-i18n-core/src/directive' export { I18nPluginOptions } from '../../vue-i18n-core/src/plugin' export { VERSION } from './../../vue-i18n-core/src/misc' export { Disposer } from './../../vue-i18n-core/src/types' export type { - IsNever, IsEmptyObject, - PickupPaths, + IsNever, + PickupFormatPathKeys, PickupKeys, - PickupFormatPathKeys + PickupPaths } from '@intlify/core-base' // NOTE: experimental !! diff --git a/packages/vue-i18n/src/runtime.ts b/packages/vue-i18n/src/runtime.ts index 4ea64a04a..b3b0bfeb5 100644 --- a/packages/vue-i18n/src/runtime.ts +++ b/packages/vue-i18n/src/runtime.ts @@ -1,13 +1,13 @@ -import { getGlobalThis } from '@intlify/shared' import { - setDevToolsHook, compile, + fallbackWithLocaleChain, + registerLocaleFallbacker, registerMessageCompiler, registerMessageResolver, resolveValue, - registerLocaleFallbacker, - fallbackWithLocaleChain + setDevToolsHook } from '@intlify/core-base' +import { getGlobalThis } from '@intlify/shared' import { initDev, initFeatureFlags } from '../../vue-i18n-core/src/misc' if (__ESM_BUNDLER__ && !__TEST__) { @@ -24,115 +24,114 @@ registerMessageResolver(resolveValue) registerLocaleFallbacker(fallbackWithLocaleChain) export { - Path, - PathValue, - NamedValue, - Locale, + CompileError, + DateTimeOptions, FallbackLocale, - LocaleMessageValue, - LocaleMessageDictionary, - LocaleMessageType, - LocaleMessages, - NumberFormat as IntlNumberFormat, DateTimeFormat as IntlDateTimeFormat, DateTimeFormats as IntlDateTimeFormats, - NumberFormats as IntlNumberFormats, - LocaleMatcher as IntlLocaleMatcher, FormatMatcher as IntlFormatMatcher, - MessageFunction, - MessageFunctions, - PluralizationRule, + LocaleMatcher as IntlLocaleMatcher, + NumberFormat as IntlNumberFormat, + NumberFormats as IntlNumberFormats, LinkedModifiers, - TranslateOptions, - DateTimeOptions, - NumberOptions, - PostTranslationHandler, - MessageResolver, + Locale, + LocaleMessageDictionary, + LocaleMessages, + LocaleMessageType, + LocaleMessageValue, MessageCompiler, MessageCompilerContext, - CompileError, MessageContext, - RemovedIndexResources + MessageFunction, + MessageFunctions, + MessageResolver, + NamedValue, + NumberOptions, + Path, + PathValue, + PluralizationRule, + PostTranslationHandler, + RemovedIndexResources, + TranslateOptions } from '@intlify/core-base' export { - VueMessageType, - DefineLocaleMessage, - DefaultLocaleMessageSchema, - DefineDateTimeFormat, - DefaultDateTimeFormatSchema, - DefineNumberFormat, - DefaultNumberFormatSchema, - MissingHandler, - ComposerOptions, + BaseFormatProps, + ComponentI18nScope, + DatetimeFormat, + DatetimeFormatProps, + FormattableProps, + I18nD, + I18nN, + I18nT, + NumberFormat, + NumberFormatProps, + Translation, + TranslationProps +} from '../../vue-i18n-core/src/components' +export { Composer, ComposerCustom, - CustomBlock, - CustomBlocks, - ComposerTranslation, ComposerDateTimeFormatting, ComposerNumberFormatting, - ComposerResolveLocaleMessageTranslation + ComposerOptions, + ComposerResolveLocaleMessageTranslation, + ComposerTranslation, + CustomBlock, + CustomBlocks, + DefaultDateTimeFormatSchema, + DefaultLocaleMessageSchema, + DefaultNumberFormatSchema, + DefineDateTimeFormat, + DefineLocaleMessage, + DefineNumberFormat, + MissingHandler, + VueMessageType } from '../../vue-i18n-core/src/composer' export { - TranslateResult, + TranslationDirective, + vTDirective, + VTDirectiveValue +} from '../../vue-i18n-core/src/directive' +export { + ComposerAdditionalOptions, + ComposerExtender, + createI18n, + ExportedGlobalComposer, + I18n, + I18nAdditionalOptions, + I18nInjectionKey, + I18nMode, + I18nOptions, + I18nScope, + useI18n, + UseI18nOptions +} from '../../vue-i18n-core/src/i18n' +export { Choice, - LocaleMessageObject, - PluralizationRulesMap, - WarnHtmlInMessageLevel, DateTimeFormatResult, + LocaleMessageObject, NumberFormatResult, - VueI18nOptions, + PluralizationRulesMap, + TranslateResult, VueI18n, - VueI18nTranslation, - VueI18nTranslationChoice, VueI18nDateTimeFormatting, + VueI18nExtender, VueI18nNumberFormatting, + VueI18nOptions, VueI18nResolveLocaleMessageTranslation, - VueI18nExtender + VueI18nTranslation, + WarnHtmlInMessageLevel } from '../../vue-i18n-core/src/legacy' -export { - createI18n, - useI18n, - I18nInjectionKey, - I18nOptions, - I18nAdditionalOptions, - I18n, - I18nMode, - I18nScope, - ComposerAdditionalOptions, - UseI18nOptions, - ExportedGlobalComposer, - ComposerExtender -} from '../../vue-i18n-core/src/i18n' -export { - Translation, - I18nT, - NumberFormat, - I18nN, - DatetimeFormat, - I18nD, - TranslationProps, - NumberFormatProps, - DatetimeFormatProps, - FormattableProps, - BaseFormatProps, - ComponentI18nScope -} from '../../vue-i18n-core/src/components' -export { - vTDirective, - VTDirectiveValue, - TranslationDirective -} from '../../vue-i18n-core/src/directive' export { I18nPluginOptions } from '../../vue-i18n-core/src/plugin' export { VERSION } from './../../vue-i18n-core/src/misc' export { Disposer } from './../../vue-i18n-core/src/types' export type { - IsNever, IsEmptyObject, - PickupPaths, + IsNever, + PickupFormatPathKeys, PickupKeys, - PickupFormatPathKeys + PickupPaths } from '@intlify/core-base' // NOTE: experimental !! diff --git a/packages/vue-i18n/src/vue.d.ts b/packages/vue-i18n/src/vue.d.ts index f7475dead..adee667c2 100644 --- a/packages/vue-i18n/src/vue.d.ts +++ b/packages/vue-i18n/src/vue.d.ts @@ -1,37 +1,36 @@ -import type { NamedValue, JsonPaths } from '@intlify/core-base' import type { + DateTimeOptions, + IsEmptyObject, + IsNever, + JsonPaths, Locale, LocaleMessageValue, MessageFunction, - TranslateOptions, - DateTimeOptions, + NamedValue, NumberOptions, - IsNever, - IsEmptyObject, - PickupFormatPathKeys + PickupFormatPathKeys, + TranslateOptions } from '@intlify/core-base' import type { - CustomBlocks, - VueMessageType -} from '../../vue-i18n-core/src/composer' + DatetimeFormat, + NumberFormat, + Translation +} from '../../vue-i18n-core/src/components' import type { - DefineLocaleMessage, + CustomBlocks, DefineDateTimeFormat, - RemovedIndexResources + DefineLocaleMessage, + RemovedIndexResources, + VueMessageType } from '../../vue-i18n-core/src/composer' +import type { ExportedGlobalComposer } from '../../vue-i18n-core/src/i18n' import type { - VueI18n, - VueI18nOptions, - TranslateResult, DateTimeFormatResult, - NumberFormatResult + NumberFormatResult, + TranslateResult, + VueI18n, + VueI18nOptions } from '../../vue-i18n-core/src/legacy' -import type { ExportedGlobalComposer } from '../../vue-i18n-core/src/i18n' -import type { - Translation, - DatetimeFormat, - NumberFormat -} from '../../vue-i18n-core/src/components' // --- THE CONTENT BELOW THIS LINE WILL BE APPENDED TO DTS FILE IN DIST DIRECTORY --- // declare module 'vue' { @@ -487,226 +486,6 @@ declare module 'vue' { named: NamedValue, options?: TranslateOptions ): string - /** - * Locale message pluralization - * - * @remarks - * If this is used in a reactive context, it will re-evaluate once the locale changes. - * - * The input / output is the same as for VueI18n instance. About that details, see {@link VueI18n#tc | `VueI18n#tc` }. - * The value of plural is handled with default `1`. - * Supported for Legacy API mode only. - * - * @param key - A target locale message key - * - * @returns translation message that is pluraled - */ - $tc< - Key extends string, - DefinedLocaleMessage extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? JsonPaths<{ - [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - key: Key | ResourceKeys - ): TranslateResult - /** - * Locale message pluralization - * - * @remarks - * Overloaded `$tc`. About details, see the {@link $tc} remarks. - * Supported for Legacy API mode only. - * - * @param key - A target locale message key - * @param locale - A locale, override locale that global scope or local scope - * - * @returns translation message that is pluraled - */ - $tc< - Key extends string, - DefinedLocaleMessage extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? JsonPaths<{ - [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - key: Key | ResourceKeys, - locale: Locale - ): TranslateResult - /** - * Locale message pluralization - * - * @remarks - * Overloaded `$tc`. About details, see the {@link $tc} remarks. - * Supported for Legacy API mode only. - * - * @param key - A target locale message key - * @param list - A values of list interpolation - * - * @returns translation message that is pluraled - */ - $tc< - Key extends string, - DefinedLocaleMessage extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? JsonPaths<{ - [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - key: Key | ResourceKeys, - list: unknown[] - ): TranslateResult - /** - * Locale message pluralization - * Supported for Legacy API mode only. - * - * @remarks - * Overloaded `$tc`. About details, see the {@link $tc} remarks. - * Supported for Legacy API mode only. - * - * @param key - A target locale message key - * @param named - A values of named interpolation - * - * @returns translation message that is pluraled - */ - $tc< - Key extends string, - DefinedLocaleMessage extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? JsonPaths<{ - [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - key: Key | ResourceKeys, - named: Record - ): TranslateResult - /** - * Locale message pluralization - * Supported for Legacy API mode only. - * - * @remarks - * Overloaded `$tc`. About details, see the {@link $tc} remarks. - * Supported for Legacy API mode only. - * - * @param key - A target locale message key - * @param choice - Which plural string to get. 1 returns the first one. - * - * @returns translation message that is pluraled - */ - $tc< - Key extends string, - DefinedLocaleMessage extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? JsonPaths<{ - [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - key: Key | ResourceKeys, - choice: number - ): TranslateResult - /** - * Locale message pluralization - * Supported for Legacy API mode only. - * - * @remarks - * Overloaded `$tc`. About details, see the {@link $tc} remarks. - * Supported for Legacy API mode only. - * - * @param key - A target locale message key - * @param choice - Which plural string to get. 1 returns the first one. - * @param locale - A locale, override locale that global scope or local scope - * - * @returns translation message that is pluraled - */ - $tc< - Key extends string, - DefinedLocaleMessage extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? JsonPaths<{ - [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - key: Key | ResourceKeys, - choice: number, - locale: Locale - ): TranslateResult - /** - * Locale message pluralization - * Supported for Legacy API mode only. - * - * @remarks - * Overloaded `$tc`. About details, see the {@link $tc} remarks. - * Supported for Legacy API mode only. - * - * @param key - A target locale message key - * @param choice - Which plural string to get. 1 returns the first one. - * @param list - A values of list interpolation - * - * @returns translation message that is pluraled - */ - $tc< - Key extends string, - DefinedLocaleMessage extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? JsonPaths<{ - [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - key: Key | ResourceKeys, - choice: number, - list: unknown[] - ): TranslateResult - /** - * Locale message pluralization - * Supported for Legacy API mode only. - * - * @remarks - * Overloaded `$tc`. About details, see the {@link $tc} remarks. - * Supported for Legacy API mode only. - * - * @param key - A target locale message key - * @param choice - Which plural string to get. 1 returns the first one. - * @param named - A values of named interpolation - * - * @returns translation message that is pluraled - */ - $tc< - Key extends string, - DefinedLocaleMessage extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? JsonPaths<{ - [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - key: Key | ResourceKeys, - choice: number, - named: Record - ): TranslateResult /** * Translation message exist *