diff --git a/packages/vue-i18n-core/src/composer.ts b/packages/vue-i18n-core/src/composer.ts index 4a24ecd9c..bcafd5a0e 100644 --- a/packages/vue-i18n-core/src/composer.ts +++ b/packages/vue-i18n-core/src/composer.ts @@ -2339,7 +2339,7 @@ export function createComposer(options: any = {}, VueI18nLegacy?: any): any { if (!key) return false const targetLocale = isString(locale) ? locale : _locale.value const message = getLocaleMessage(targetLocale) - return _context.messageResolver(message, key) !== null + return isString(_context.messageResolver(message, key)) } function resolveMessages(key: Path): LocaleMessageValue | null { diff --git a/packages/vue-i18n-core/test/composer.test.ts b/packages/vue-i18n-core/test/composer.test.ts index 83ca027c9..db20df2eb 100644 --- a/packages/vue-i18n-core/test/composer.test.ts +++ b/packages/vue-i18n-core/test/composer.test.ts @@ -1526,7 +1526,7 @@ describe('messageResolver', () => { }) expect(t('path.to.message')).toEqual('こんにちは') - expect(te('path.to.message')).toEqual(true) + expect(te('path.to.message')).toEqual(false) expect(tm('api.errors')).toEqual(ja['api.errors']) expect(mockMessageResolver).toHaveBeenCalledTimes(5) expect(mockMessageResolver.mock.calls[0][0]).toEqual({}) diff --git a/packages/vue-i18n-core/test/issues.test.ts b/packages/vue-i18n-core/test/issues.test.ts index 83a4900f2..9451bd05d 100644 --- a/packages/vue-i18n-core/test/issues.test.ts +++ b/packages/vue-i18n-core/test/issues.test.ts @@ -1050,6 +1050,38 @@ test('issue #1547', async () => { expect(wrapper.html()).toEqual('
Deep Linked message
') }) +test('issue #1559', async () => { + const i18n = createI18n({ + legacy: false, + locale: 'en', + messages: { + en: { + hello: 'Hello, Vue I18n', + language: 'Languages', + keyAndNotTranslation: { + entry1: 'TRANSLATION FOR sub entry1', + entry2: 'TRANSLATION FOR sub entry2' + } + } + } + }) + + const App = defineComponent({ + setup() { + const { t } = useI18n() + return { t } + }, + template: ` +

{{ t('keyAndNotTranslation.entry1') }}

+
{{ $t('keyAndNotTranslation') }}
` + }) + const wrapper = await mount(App, i18n) + + expect(wrapper.html()).toEqual( + '

TRANSLATION FOR sub entry1

' + ) +}) + test('issue #1595', async () => { const i18n = createI18n({ legacy: false,