diff --git a/docs/guide/migration/vue3.md b/docs/guide/migration/vue3.md
index ec2fb25e6..e80300419 100644
--- a/docs/guide/migration/vue3.md
+++ b/docs/guide/migration/vue3.md
@@ -16,7 +16,7 @@ From Vue I18n v9.2, the Legacy API mode can also be used with Composition API mo
### About supporting
-:::warning NOTICE
+:::danger NOTICE
This migration support will be removed in the next major version v10. If your Vue 3 application project has not yet been migrated, please migrate it to v9 and then upgrade to v10.
:::
diff --git a/e2e/composition.spec.ts b/e2e/composition.spec.ts
deleted file mode 100644
index 65d5bf86b..000000000
--- a/e2e/composition.spec.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { getText } from './helper'
-;['legacy'].forEach(pattern => {
- describe(`${pattern}`, () => {
- beforeAll(async () => {
- await page.goto(
- `http://localhost:8080/examples/${pattern}/composition.html`
- )
- })
-
- test('initial rendering', async () => {
- expect(await getText(page, '#app p.parent')).toMatch('こんにちは、世界!')
- expect(await getText(page, '#app p.child')).toMatch('Hi there!')
- })
-
- test('change locale', async () => {
- // root
- await page.selectOption('#app select', 'en')
- expect(await getText(page, '#app p.parent')).toMatch('hello world!')
- expect(await getText(page, '#app p.child')).toMatch('Hi there!')
-
- // Child
- await page.selectOption('#app div.child select', 'ja')
- expect(await getText(page, '#app p.parent')).toMatch('hello world!')
- expect(await getText(page, '#app p.child')).toMatch('やあ!')
- })
- })
-})
diff --git a/examples/legacy/composition.html b/examples/legacy/composition.html
deleted file mode 100644
index 1dee97464..000000000
--- a/examples/legacy/composition.html
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
-
- Allow Composition API on legacy example
-
-
-
-
-
-
Root
-
-
{{ $t("message.hello") }}
-
-
-
-
-
diff --git a/packages/vue-i18n-core/src/errors.ts b/packages/vue-i18n-core/src/errors.ts
index b0d07ea8e..e0458cf4e 100644
--- a/packages/vue-i18n-core/src/errors.ts
+++ b/packages/vue-i18n-core/src/errors.ts
@@ -16,23 +16,20 @@ export const I18nErrorCodes = {
// i18n module errors
MUST_BE_CALL_SETUP_TOP: inc(), // 26
NOT_INSTALLED: inc(), // 27
- NOT_AVAILABLE_IN_LEGACY_MODE: inc(), // 28
// directive module errors
- REQUIRED_VALUE: inc(), // 29
- INVALID_VALUE: inc(), // 30
+ REQUIRED_VALUE: inc(), // 28
+ INVALID_VALUE: inc(), // 29
// vue-devtools errors
- CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN: inc(), // 31
- NOT_INSTALLED_WITH_PROVIDE: inc(), // 32
+ CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN: inc(), // 30
+ NOT_INSTALLED_WITH_PROVIDE: inc(), // 31
// unexpected error
- UNEXPECTED_ERROR: inc(), // 33
+ UNEXPECTED_ERROR: inc(), // 32
// not compatible legacy vue-i18n constructor
- NOT_COMPATIBLE_LEGACY_VUE_I18N: inc(), // 34
- // need to define `i18n` option in `allowComposition: true` and `useScope: 'local' at `useI18n``
- MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION: inc(), // 35
+ NOT_COMPATIBLE_LEGACY_VUE_I18N: inc(), // 33
// Not available Compostion API in Legacy API mode. Please make sure that the legacy API mode is working properly
- NOT_AVAILABLE_COMPOSITION_IN_LEGACY: inc(), // 36
+ NOT_AVAILABLE_COMPOSITION_IN_LEGACY: inc(), // 34
// for enhancement
- __EXTEND_POINT__: inc() // 3
+ __EXTEND_POINT__: inc() // 35
} as const
type I18nErrorCodes = (typeof I18nErrorCodes)[keyof typeof I18nErrorCodes]
@@ -55,7 +52,6 @@ export const errorMessages: { [code: number]: string } = {
'Must be called at the top of a `setup` function',
[I18nErrorCodes.NOT_INSTALLED]: 'Need to install with `app.use` function',
[I18nErrorCodes.UNEXPECTED_ERROR]: 'Unexpected error',
- [I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE]: 'Not available in legacy mode',
[I18nErrorCodes.REQUIRED_VALUE]: `Required in value: {0}`,
[I18nErrorCodes.INVALID_VALUE]: `Invalid value`,
[I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN]: `Cannot setup vue-devtools plugin`,
@@ -63,8 +59,6 @@ export const errorMessages: { [code: number]: string } = {
'Need to install with `provide` function',
[I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N]:
'Not compatible legacy VueI18n.',
- [I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION]:
- 'Must define ‘i18n’ option or custom block in Composition API with using local scope in Legacy API mode',
[I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY]:
'Not available Compostion API in Legacy API mode. Please make sure that the legacy API mode is working properly'
}
diff --git a/packages/vue-i18n-core/src/i18n.ts b/packages/vue-i18n-core/src/i18n.ts
index 59ddb20c9..ddec2edc6 100644
--- a/packages/vue-i18n-core/src/i18n.ts
+++ b/packages/vue-i18n-core/src/i18n.ts
@@ -1,30 +1,22 @@
import {
inject,
- onBeforeMount,
onMounted,
onUnmounted,
InjectionKey,
getCurrentInstance,
- shallowRef,
isRef,
- ref,
- computed,
effectScope
} from 'vue'
import {
isEmptyObject,
isBoolean,
- isString,
- isArray,
isPlainObject,
- isRegExp,
- isFunction,
warn,
makeSymbol,
createEmitter,
assign
} from '@intlify/shared'
-import { createComposer, DEFAULT_LOCALE } from './composer'
+import { createComposer } from './composer'
import { createVueI18n } from './legacy'
import { I18nWarnCodes, getWarnMessage } from './warnings'
import { I18nErrorCodes, createI18nError } from './errors'
@@ -37,30 +29,14 @@ import {
import { apply as applyPlugin } from './plugin/next'
import { defineMixin } from './mixins'
import { enableDevTools, addTimelineEvent } from './devtools'
-import {
- getComponentOptions,
- getLocaleMessages,
- adjustI18nResources
-} from './utils'
+import { getComponentOptions, adjustI18nResources } from './utils'
import type { ComponentInternalInstance, App, EffectScope } from 'vue'
import type {
Locale,
- Path,
FallbackLocale,
SchemaParams,
- LocaleMessages,
- LocaleMessage,
- LocaleMessageValue,
- LocaleMessageDictionary,
- PostTranslationHandler,
- DateTimeFormats as DateTimeFormatsType,
- NumberFormats as NumberFormatsType,
- DateTimeFormat,
- NumberFormat,
- LocaleParams,
- LinkedModifiers,
- PluralizationRules
+ LocaleParams
} from '@intlify/core-base'
import type {
VueDevToolsEmitter,
@@ -68,7 +44,6 @@ import type {
} from '@intlify/vue-devtools'
import type {
VueMessageType,
- MissingHandler,
DefaultLocaleMessageSchema,
DefaultDateTimeFormatSchema,
DefaultNumberFormatSchema,
@@ -171,18 +146,6 @@ export interface I18nAdditionalOptions {
* @defaultValue `true`
*/
globalInjection?: boolean
- /**
- * Whether to allow the Composition API to be used in Legacy API mode.
- *
- * @remarks
- * If this option is enabled, you can use {@link useI18n} in Legacy API mode. This option is supported to support the migration from Legacy API mode to Composition API mode.
- *
- * @VueI18nWarning Note that the Composition API made available with this option doesn't work on SSR.
- * @VueI18nSee [Composition API](../guide/advanced/composition)
- *
- * @defaultValue `false`
- */
- allowComposition?: boolean
}
/**
@@ -232,13 +195,6 @@ export interface I18n<
: Legacy extends false
? Composer
: unknown
- /**
- * The property whether or not the Composition API is available
- *
- * @remarks
- * If you specified `allowComposition: true` option in Legacy API mode, return `true`, else `false`. else you use the Composition API mode, this property will always return `true`.
- */
- readonly allowComposition: boolean
/**
* Install entry point
*
@@ -526,12 +482,6 @@ export function createI18n(options: any = {}, VueI18nLegacy?: any): any {
const __globalInjection = isBoolean(options.globalInjection)
? options.globalInjection
: true
- // prettier-ignore
- const __allowComposition = __LITE__
- ? true
- : __FEATURE_LEGACY_API__ && __legacyMode
- ? !!options.allowComposition
- : true
const __instances = new Map()
const [globalScope, __global] = createGlobal(
options,
@@ -542,12 +492,6 @@ export function createI18n(options: any = {}, VueI18nLegacy?: any): any {
__DEV__ ? 'vue-i18n' : ''
)
- if (__DEV__) {
- if (__legacyMode && __allowComposition && !__TEST__) {
- warn(getWarnMessage(I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION))
- }
- }
-
function __getInstance(
component: ComponentInternalInstance
): Instance | null {
@@ -570,10 +514,6 @@ export function createI18n(options: any = {}, VueI18nLegacy?: any): any {
? 'legacy'
: 'composition'
},
- // allowComposition
- get allowComposition(): boolean {
- return __allowComposition
- },
// install plugin
async install(app: App, ...options: unknown[]): Promise {
if ((__DEV__ || __FEATURE_PROD_VUE_DEVTOOLS__) && !__NODE_JS__) {
@@ -773,16 +713,6 @@ export function useI18n<
const componentOptions = getComponentOptions(instance)
const scope = getScope(options, componentOptions)
- if (!__LITE__ && __FEATURE_LEGACY_API__) {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- if (i18n.mode === 'legacy' && !(options as any).__useComponent) {
- if (!i18n.allowComposition) {
- throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE)
- }
- return useI18nForLegacy(instance, scope, gl, options)
- }
- }
-
if (scope === 'global') {
adjustI18nResources(gl, options, componentOptions)
return gl as unknown as Composer<
@@ -999,452 +929,6 @@ function setupLifeCycle(
}, target)
}
-function useI18nForLegacy(
- instance: ComponentInternalInstance,
- scope: I18nScope,
- root: Composer,
- options: any = {} // eslint-disable-line @typescript-eslint/no-explicit-any
-): Composer {
- type Message = VueMessageType
-
- const isLocalScope = scope === 'local'
- const _composer = shallowRef(null)
-
- if (
- isLocalScope &&
- instance.proxy &&
- !(instance.proxy.$options.i18n || instance.proxy.$options.__i18n)
- ) {
- throw createI18nError(
- I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION
- )
- }
-
- const _inheritLocale = isBoolean(options.inheritLocale)
- ? options.inheritLocale
- : !isString(options.locale)
-
- const _locale = ref(
- // prettier-ignore
- !isLocalScope || _inheritLocale
- ? root.locale.value
- : isString(options.locale)
- ? options.locale
- : DEFAULT_LOCALE
- )
-
- const _fallbackLocale = ref(
- // prettier-ignore
- !isLocalScope || _inheritLocale
- ? root.fallbackLocale.value
- : isString(options.fallbackLocale) ||
- isArray(options.fallbackLocale) ||
- isPlainObject(options.fallbackLocale) ||
- options.fallbackLocale === false
- ? options.fallbackLocale
- : _locale.value
- )
-
- const _messages = ref>>(
- getLocaleMessages>>(
- _locale.value as Locale,
- options
- )
- )
-
- // prettier-ignore
- const _datetimeFormats = ref(
- isPlainObject(options.datetimeFormats)
- ? options.datetimeFormats
- : { [_locale.value]: {} }
- )
-
- // prettier-ignore
- const _numberFormats = ref(
- isPlainObject(options.numberFormats)
- ? options.numberFormats
- : { [_locale.value]: {} }
- )
-
- // prettier-ignore
- const _missingWarn = isLocalScope
- ? root.missingWarn
- : isBoolean(options.missingWarn) || isRegExp(options.missingWarn)
- ? options.missingWarn
- : true
-
- // prettier-ignore
- const _fallbackWarn = isLocalScope
- ? root.fallbackWarn
- : isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn)
- ? options.fallbackWarn
- : true
-
- // prettier-ignore
- const _fallbackRoot = isLocalScope
- ? root.fallbackRoot
- : isBoolean(options.fallbackRoot)
- ? options.fallbackRoot
- : true
-
- // configure fall back to root
- const _fallbackFormat = !!options.fallbackFormat
-
- // runtime missing
- const _missing = isFunction(options.missing) ? options.missing : null
-
- // postTranslation handler
- const _postTranslation = isFunction(options.postTranslation)
- ? options.postTranslation
- : null
-
- // prettier-ignore
- const _warnHtmlMessage = isLocalScope
- ? root.warnHtmlMessage
- : isBoolean(options.warnHtmlMessage)
- ? options.warnHtmlMessage
- : true
-
- const _escapeParameter = !!options.escapeParameter
-
- // prettier-ignore
- const _modifiers = isLocalScope
- ? root.modifiers
- : isPlainObject(options.modifiers)
- ? options.modifiers
- : {}
-
- // pluralRules
- const _pluralRules = options.pluralRules || (isLocalScope && root.pluralRules)
-
- // track reactivity
- function trackReactivityValues() {
- return [
- _locale.value,
- _fallbackLocale.value,
- _messages.value,
- _datetimeFormats.value,
- _numberFormats.value
- ]
- }
-
- // locale
- const locale = computed({
- get: () => {
- return _composer.value ? _composer.value.locale.value : _locale.value
- },
- set: val => {
- if (_composer.value) {
- _composer.value.locale.value = val
- }
- _locale.value = val
- }
- })
-
- // fallbackLocale
- const fallbackLocale = computed({
- get: () => {
- return _composer.value
- ? _composer.value.fallbackLocale.value
- : _fallbackLocale.value
- },
- set: val => {
- if (_composer.value) {
- _composer.value.fallbackLocale.value = val
- }
- _fallbackLocale.value = val
- }
- })
-
- // messages
- const messages = computed, Message>>(
- () => {
- if (_composer.value) {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return _composer.value.messages.value as any
- } else {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return _messages.value as any
- }
- }
- )
-
- const datetimeFormats = computed(
- () => _datetimeFormats.value
- )
-
- const numberFormats = computed(() => _numberFormats.value)
-
- function getPostTranslationHandler(): PostTranslationHandler | null {
- return _composer.value
- ? _composer.value.getPostTranslationHandler()
- : _postTranslation
- }
-
- function setPostTranslationHandler(
- handler: PostTranslationHandler | null
- ): void {
- if (_composer.value) {
- _composer.value.setPostTranslationHandler(handler)
- }
- }
-
- function getMissingHandler(): MissingHandler | null {
- return _composer.value ? _composer.value.getMissingHandler() : _missing
- }
-
- function setMissingHandler(handler: MissingHandler | null): void {
- if (_composer.value) {
- _composer.value.setMissingHandler(handler)
- }
- }
-
- function warpWithDeps(fn: () => unknown) {
- trackReactivityValues()
- return fn() as R
- }
-
- function t(...args: unknown[]): string {
- return _composer.value
- ? warpWithDeps(
- () => Reflect.apply(_composer.value!.t, null, [...args]) as string
- )
- : warpWithDeps(() => '')
- }
-
- function rt(...args: unknown[]): string {
- return _composer.value
- ? Reflect.apply(_composer.value.rt, null, [...args])
- : ''
- }
-
- function d(...args: unknown[]): string {
- return _composer.value
- ? warpWithDeps(
- () => Reflect.apply(_composer.value!.d, null, [...args]) as string
- )
- : warpWithDeps(() => '')
- }
-
- function n(...args: unknown[]): string {
- return _composer.value
- ? warpWithDeps(
- () => Reflect.apply(_composer.value!.n, null, [...args]) as string
- )
- : warpWithDeps(() => '')
- }
-
- function tm(key: Path): LocaleMessageValue | {} {
- return _composer.value ? _composer.value.tm(key) : {}
- }
-
- function te(key: Path, locale?: Locale): boolean {
- return _composer.value ? _composer.value.te(key, locale) : false
- }
-
- function getLocaleMessage(locale: Locale): LocaleMessage {
- return _composer.value ? _composer.value.getLocaleMessage(locale) : {}
- }
-
- function setLocaleMessage(locale: Locale, message: LocaleMessage) {
- if (_composer.value) {
- _composer.value.setLocaleMessage(locale, message)
- _messages.value[locale] = message
- }
- }
-
- function mergeLocaleMessage(
- locale: Locale,
- message: LocaleMessageDictionary
- ): void {
- if (_composer.value) {
- _composer.value.mergeLocaleMessage(locale, message)
- }
- }
-
- function getDateTimeFormat(locale: Locale): DateTimeFormat {
- return _composer.value ? _composer.value.getDateTimeFormat(locale) : {}
- }
-
- function setDateTimeFormat(locale: Locale, format: DateTimeFormat): void {
- if (_composer.value) {
- _composer.value.setDateTimeFormat(locale, format)
- _datetimeFormats.value[locale] = format
- }
- }
-
- function mergeDateTimeFormat(locale: Locale, format: DateTimeFormat): void {
- if (_composer.value) {
- _composer.value.mergeDateTimeFormat(locale, format)
- }
- }
-
- function getNumberFormat(locale: Locale): NumberFormat {
- return _composer.value ? _composer.value.getNumberFormat(locale) : {}
- }
-
- function setNumberFormat(locale: Locale, format: NumberFormat): void {
- if (_composer.value) {
- _composer.value.setNumberFormat(locale, format)
- _numberFormats.value[locale] = format
- }
- }
-
- function mergeNumberFormat(locale: Locale, format: NumberFormat): void {
- if (_composer.value) {
- _composer.value.mergeNumberFormat(locale, format)
- }
- }
-
- const wrapper = {
- get id(): number {
- return _composer.value ? _composer.value.id : -1
- },
- locale,
- fallbackLocale,
- messages,
- datetimeFormats,
- numberFormats,
- get inheritLocale(): boolean {
- return _composer.value ? _composer.value.inheritLocale : _inheritLocale
- },
- set inheritLocale(val: boolean) {
- if (_composer.value) {
- _composer.value.inheritLocale = val
- }
- },
- get availableLocales(): Locale[] {
- return _composer.value
- ? _composer.value.availableLocales
- : Object.keys(_messages.value)
- },
- get modifiers(): LinkedModifiers {
- return (
- _composer.value ? _composer.value.modifiers : _modifiers
- ) as LinkedModifiers
- },
- get pluralRules(): PluralizationRules {
- return (
- _composer.value ? _composer.value.pluralRules : _pluralRules
- ) as PluralizationRules
- },
- get isGlobal(): boolean {
- return _composer.value ? _composer.value.isGlobal : false
- },
- get missingWarn(): boolean | RegExp {
- return _composer.value ? _composer.value.missingWarn : _missingWarn
- },
- set missingWarn(val: boolean | RegExp) {
- if (_composer.value) {
- _composer.value.missingWarn = val
- }
- },
- get fallbackWarn(): boolean | RegExp {
- return _composer.value ? _composer.value.fallbackWarn : _fallbackWarn
- },
- set fallbackWarn(val: boolean | RegExp) {
- if (_composer.value) {
- _composer.value.missingWarn = val
- }
- },
- get fallbackRoot(): boolean {
- return _composer.value ? _composer.value.fallbackRoot : _fallbackRoot
- },
- set fallbackRoot(val: boolean) {
- if (_composer.value) {
- _composer.value.fallbackRoot = val
- }
- },
- get fallbackFormat(): boolean {
- return _composer.value ? _composer.value.fallbackFormat : _fallbackFormat
- },
- set fallbackFormat(val: boolean) {
- if (_composer.value) {
- _composer.value.fallbackFormat = val
- }
- },
- get warnHtmlMessage(): boolean {
- return _composer.value
- ? _composer.value.warnHtmlMessage
- : _warnHtmlMessage
- },
- set warnHtmlMessage(val: boolean) {
- if (_composer.value) {
- _composer.value.warnHtmlMessage = val
- }
- },
- get escapeParameter(): boolean {
- return _composer.value
- ? _composer.value.escapeParameter
- : _escapeParameter
- },
- set escapeParameter(val: boolean) {
- if (_composer.value) {
- _composer.value.escapeParameter = val
- }
- },
- t,
- getPostTranslationHandler,
- setPostTranslationHandler,
- getMissingHandler,
- setMissingHandler,
- rt,
- d,
- n,
- tm,
- te,
- getLocaleMessage,
- setLocaleMessage,
- mergeLocaleMessage,
- getDateTimeFormat,
- setDateTimeFormat,
- mergeDateTimeFormat,
- getNumberFormat,
- setNumberFormat,
- mergeNumberFormat
- }
-
- function sync(composer: Composer): void {
- composer.locale.value = _locale.value
- composer.fallbackLocale.value = _fallbackLocale.value
- Object.keys(_messages.value).forEach(locale => {
- composer.mergeLocaleMessage(locale, _messages.value[locale])
- })
- Object.keys(_datetimeFormats.value).forEach(locale => {
- composer.mergeDateTimeFormat(locale, _datetimeFormats.value[locale])
- })
- Object.keys(_numberFormats.value).forEach(locale => {
- composer.mergeNumberFormat(locale, _numberFormats.value[locale])
- })
- composer.escapeParameter = _escapeParameter
- composer.fallbackFormat = _fallbackFormat
- composer.fallbackRoot = _fallbackRoot
- composer.fallbackWarn = _fallbackWarn
- composer.missingWarn = _missingWarn
- composer.warnHtmlMessage = _warnHtmlMessage
- }
-
- onBeforeMount(() => {
- if (instance.proxy == null || instance.proxy.$i18n == null) {
- throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY)
- }
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const composer = (_composer.value = (instance.proxy.$i18n as any)
- .__composer as Composer)
- if (scope === 'global') {
- _locale.value = composer.locale.value
- _fallbackLocale.value = composer.fallbackLocale.value
- _messages.value = composer.messages.value
- _datetimeFormats.value = composer.datetimeFormats.value
- _numberFormats.value = composer.numberFormats.value
- } else if (isLocalScope) {
- sync(composer)
- }
- })
-
- return wrapper as unknown as Composer
-}
-
/**
* Exported global composer instance
*
diff --git a/packages/vue-i18n-core/src/warnings.ts b/packages/vue-i18n-core/src/warnings.ts
index d698ed909..1825474d3 100644
--- a/packages/vue-i18n-core/src/warnings.ts
+++ b/packages/vue-i18n-core/src/warnings.ts
@@ -13,8 +13,7 @@ export const I18nWarnCodes = {
COMPONENT_NAME_LEGACY_COMPATIBLE: inc(), // 13
NOT_FOUND_PARENT_SCOPE: inc(), // 14
IGNORE_OBJ_FLATTEN: inc(), // 15
- NOTICE_DROP_ALLOW_COMPOSITION: inc(), // 16
- NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG: inc() // 17
+ NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG: inc() // 16
} as const
type I18nWarnCodes = (typeof I18nWarnCodes)[keyof typeof I18nWarnCodes]
@@ -28,7 +27,6 @@ export const warnMessages: { [code: number]: string } = {
[I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE]: `Component name legacy compatible: '{name}' -> 'i18n'`,
[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.NOTICE_DROP_ALLOW_COMPOSITION]: `'allowComposition' option will be dropped in the next major version. For more information, please see 👉 https://tinyurl.com/2p97mcze`,
[I18nWarnCodes.NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG]: `'translateExistCompatible' option will be dropped in the next major version.`
}
diff --git a/packages/vue-i18n-core/test/i18n.test.ts b/packages/vue-i18n-core/test/i18n.test.ts
index 7ff864ac3..7fa6203c2 100644
--- a/packages/vue-i18n-core/test/i18n.test.ts
+++ b/packages/vue-i18n-core/test/i18n.test.ts
@@ -96,41 +96,6 @@ describe('createI18n with flat json messages', () => {
})
})
-describe('allowComposition option', () => {
- describe('legacy mode', () => {
- test('default', () => {
- const i18n = createI18n({})
- expect(i18n.allowComposition).toEqual(false)
- })
-
- test('specify `true`', () => {
- const i18n = createI18n({
- allowComposition: true
- })
-
- expect(i18n.allowComposition).toEqual(true)
- })
- })
-
- describe('composition mode', () => {
- test('default', () => {
- const i18n = createI18n({
- legacy: false
- })
- expect(i18n.allowComposition).toEqual(true)
- })
-
- test('specify `false`', () => {
- const i18n = createI18n({
- legacy: false,
- allowComposition: false
- })
-
- expect(i18n.allowComposition).toEqual(true)
- })
- })
-})
-
describe('useI18n', () => {
let org: any // eslint-disable-line @typescript-eslint/no-explicit-any
let spy: any // eslint-disable-line @typescript-eslint/no-explicit-any
@@ -408,47 +373,6 @@ describe('useI18n', () => {
})
describe('On legacy', () => {
- describe('default', () => {
- test(
- errorMessages[I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE],
- async () => {
- const i18n = createI18n({
- legacy: true,
- locale: 'ja',
- messages: {
- en: {
- hello: 'hello!'
- }
- }
- })
-
- let error = ''
- const App = defineComponent({
- setup() {
- try {
- useI18n({
- locale: 'en',
- messages: {
- en: {
- hello: 'hello!'
- }
- }
- })
- } catch (e: any) {
- error = e.message
- }
- return {}
- },
- template: `foo
`
- })
- await mount(App, i18n)
- expect(error).toEqual(
- errorMessages[I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE]
- )
- }
- )
- })
-
describe('enable', () => {
describe('t', () => {
test('translation & locale changing', async () => {
@@ -518,41 +442,6 @@ describe('useI18n', () => {
expect(html()).toEqual('ja:世界!
')
})
- test('use i18n option', async () => {
- const i18n = createI18n({
- allowComposition: true,
- locale: 'en',
- messages: {
- en: {
- hello: 'hello!'
- },
- ja: {}
- }
- })
-
- const App = defineComponent({
- setup() {
- const { locale, t } = useI18n({
- useScope: 'local'
- })
- return { locale, t }
- },
- i18n: {
- messages: {
- en: {
- world: 'world!'
- },
- ja: {
- world: '世界!'
- }
- }
- },
- template: `{{ locale }}:{{ t('world') }}
`
- })
- const { html } = await mount(App, i18n)
- expect(html()).toEqual('en:world!
')
- })
-
test('use custom block', async () => {
const i18n = createI18n({
allowComposition: true,
@@ -591,36 +480,6 @@ describe('useI18n', () => {
const { html } = await mount(App, i18n)
expect(html()).toEqual('ja:こんにちは!
')
})
-
- test('not defined i18n option in local scope', async () => {
- const i18n = createI18n({
- allowComposition: true,
- locale: 'en',
- messages: {
- en: {
- hello: 'hello!'
- }
- }
- })
-
- let error = ''
- const App = defineComponent({
- setup() {
- try {
- useI18n({ useScope: 'local' })
- } catch (e: any) {
- error = e.message
- }
- return {}
- }
- })
- await mount(App, i18n)
- expect(error).toEqual(
- errorMessages[
- I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION
- ]
- )
- })
})
})