diff --git a/packages/vue-i18n-core/src/composer.ts b/packages/vue-i18n-core/src/composer.ts index 5bebc0c7d..efe914ece 100644 --- a/packages/vue-i18n-core/src/composer.ts +++ b/packages/vue-i18n-core/src/composer.ts @@ -13,8 +13,7 @@ import { assign, inBrowser, deepCopy, - hasOwn, - warnOnce + hasOwn } from '@intlify/shared' import { isTranslateFallbackWarn, @@ -611,24 +610,6 @@ export interface ComposerOptions< * @defaultValue `undefined` */ messageCompiler?: MessageCompiler - /** - * @remarks - * An option to make `te` behavior specification before v9.6 - * - * @VueI18nTip - * :new: v9.10+ - * - * @VueI18nWarning - * This flag will be removed in v10. - * - * @VueI18nSee [GitHub Issue](https://github.com/intlify/vue-i18n-next/issues/1738) - * - * @VueI18nSee [`te`](composition#te-key-locale) - * - * @defaultValue `false` - * - */ - translateExistCompatible?: boolean } /** @@ -1954,17 +1935,6 @@ export function createComposer(options: any = {}): any { const flatJson = options.flatJson const _ref = inBrowser ? ref : shallowRef - const translateExistCompatible = !!options.translateExistCompatible - if (__DEV__) { - if (translateExistCompatible && !__TEST__) { - warnOnce( - getWarnMessage( - I18nWarnCodes.NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG - ) - ) - } - } - let _inheritLocale = isBoolean(options.inheritLocale) ? options.inheritLocale : true @@ -2414,11 +2384,11 @@ export function createComposer(options: any = {}): any { const targetLocale = isString(locale) ? locale : _locale.value const message = getLocaleMessage(targetLocale) const resolved = _context.messageResolver(message, key) - return !translateExistCompatible - ? isMessageAST(resolved) || - isMessageFunction(resolved) || - isString(resolved) - : resolved != null + return ( + isMessageAST(resolved) || + isMessageFunction(resolved) || + isString(resolved) + ) }, () => [key], 'translate exists', diff --git a/packages/vue-i18n-core/src/legacy.ts b/packages/vue-i18n-core/src/legacy.ts index 4fe4f6f88..670071129 100644 --- a/packages/vue-i18n-core/src/legacy.ts +++ b/packages/vue-i18n-core/src/legacy.ts @@ -1487,8 +1487,6 @@ function convertComposerOptions< const datetimeFormats = options.datetimeFormats const numberFormats = options.numberFormats const flatJson = options.flatJson - const translateExistCompatible = (options as unknown as ComposerOptions) - .translateExistCompatible return { locale, @@ -1509,7 +1507,6 @@ function convertComposerOptions< escapeParameter, messageResolver: options.messageResolver, inheritLocale, - translateExistCompatible, __i18n, __root, __injectWithOption diff --git a/packages/vue-i18n-core/src/warnings.ts b/packages/vue-i18n-core/src/warnings.ts index d24c38b74..c294abb34 100644 --- a/packages/vue-i18n-core/src/warnings.ts +++ b/packages/vue-i18n-core/src/warnings.ts @@ -8,9 +8,8 @@ export const I18nWarnCodes = { FALLBACK_TO_ROOT: code, // 8 NOT_FOUND_PARENT_SCOPE: inc(), // 9 IGNORE_OBJ_FLATTEN: inc(), // 10 - NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG: inc(), // 11 - DEPRECATE_TC: inc(), // 12 - __EXTEND_POINT__: inc() // 13 + DEPRECATE_TC: inc(), // 11 + __EXTEND_POINT__: inc() // 12 } as const type I18nWarnCodes = (typeof I18nWarnCodes)[keyof typeof I18nWarnCodes] @@ -19,7 +18,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.NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG]: `'translateExistCompatible' option will be dropped in the next major version.`, [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.` } diff --git a/packages/vue-i18n-core/test/issues.test.ts b/packages/vue-i18n-core/test/issues.test.ts index c59ddb0b6..ed9fef922 100644 --- a/packages/vue-i18n-core/test/issues.test.ts +++ b/packages/vue-i18n-core/test/issues.test.ts @@ -1268,75 +1268,6 @@ test('issue #1717', async () => { }) }) -test('issue #1738', async () => { - const resources = { - en: { - messages: { - common: { - actions: { - cancel: 'Cancel' - } - } - } - }, - nl: { - messages: { - common: { - actions: { - cancel: 'Cancel' - } - } - } - } - } - - function loadTranslations(): Promise { - return new Promise(resolve => resolve(resources)) - } - - function delay(ms: number) { - return new Promise(resolve => setTimeout(resolve, ms)) - } - - const i18n = createI18n({ - locale: 'nl', - legacy: false, - translateExistCompatible: true, - fallbackLocale: 'en', - missingWarn: false, - silentFallbackWarn: true - }) - - const App = defineComponent({ - setup() { - const { mergeLocaleMessage, te } = useI18n() - onMounted(() => { - setTimeout(async () => { - const data = await loadTranslations() - - for (const key in data) { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const { messages } = (data as any)[key] - mergeLocaleMessage(key, messages) - } - }, 100) - }) - return { te } - }, - template: `
-

{{ te('common') }} - expected true

-

{{ te('common.actions') }} - expected true

-
` - }) - - const wrapper = await mount(App, i18n) - - await delay(110) - - expect(wrapper.find('#te1')?.textContent).toEqual(`true - expected true`) - expect(wrapper.find('#te2')?.textContent).toEqual(`true - expected true`) -}) - describe('issue #1768', () => { test('Implicit fallback using locales', async () => { const mockWarn = vi.spyOn(shared, 'warn') diff --git a/packages/vue-i18n-core/test/warnings.test.ts b/packages/vue-i18n-core/test/warnings.test.ts index 3211a6b50..c4acb45f8 100644 --- a/packages/vue-i18n-core/test/warnings.test.ts +++ b/packages/vue-i18n-core/test/warnings.test.ts @@ -1,5 +1,5 @@ import { I18nWarnCodes } from '../src/warnings' test('I18nWarnCodes', () => { - expect(I18nWarnCodes.__EXTEND_POINT__).toBe(13) + expect(I18nWarnCodes.__EXTEND_POINT__).toBe(12) }) diff --git a/packages/vue-i18n/src/vue.d.ts b/packages/vue-i18n/src/vue.d.ts index 88ec73ede..ec7a45ae8 100644 --- a/packages/vue-i18n/src/vue.d.ts +++ b/packages/vue-i18n/src/vue.d.ts @@ -718,7 +718,7 @@ declare module '@vue/runtime-core' { * @param key - A target locale message key * @param locale - A locale, optional, override locale that 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. + * @returns If found locale message, `true`, else `false`, Note that `false` is returned even if the value present in the key is not translatable. */ $te< Key extends string,