Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/vue-i18n-core/src/composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Message> | null {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-i18n-core/test/composer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({})
Expand Down
32 changes: 32 additions & 0 deletions packages/vue-i18n-core/test/issues.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,38 @@ test('issue #1547', async () => {
expect(wrapper.html()).toEqual('<div>Deep Linked message</div>')
})

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: `
<h1>{{ t('keyAndNotTranslation.entry1') }}</h1>
<div v-if="$te('keyAndNotTranslation')">{{ $t('keyAndNotTranslation') }}</div>`
})
const wrapper = await mount(App, i18n)

expect(wrapper.html()).toEqual(
'<h1>TRANSLATION FOR sub entry1</h1><!--v-if-->'
)
})

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