diff --git a/specs/fixtures/layer_consumer/i18n.config.ts b/specs/fixtures/layer_consumer/i18n.config.ts index edecfa78e..395c1f4e7 100644 --- a/specs/fixtures/layer_consumer/i18n.config.ts +++ b/specs/fixtures/layer_consumer/i18n.config.ts @@ -1,4 +1,5 @@ export default { + fallbackLocale: 'nl', messages: { nl: { about: 'Over deze site', diff --git a/specs/fixtures/layer_consumer/layer-simple/i18n.config.ts b/specs/fixtures/layer_consumer/layer-simple/i18n.config.ts index d5ebc188f..1274da31b 100644 --- a/specs/fixtures/layer_consumer/layer-simple/i18n.config.ts +++ b/specs/fixtures/layer_consumer/layer-simple/i18n.config.ts @@ -1,11 +1,13 @@ export default { + fallbackLocale: 'en', messages: { fr: { thanks: 'Merci!', about: 'Should be overridden' }, nl: { - thanks: 'Bedankt!' + thanks: 'Bedankt!', + uniqueTranslation: 'Unieke vertaling' }, en: { about: 'About this site', diff --git a/specs/fixtures/layer_consumer/pages/index.vue b/specs/fixtures/layer_consumer/pages/index.vue index 1bdb2ccef..7776dcfe9 100644 --- a/specs/fixtures/layer_consumer/pages/index.vue +++ b/specs/fixtures/layer_consumer/pages/index.vue @@ -22,6 +22,7 @@ useHead({
{{ $t('thanks') }}
{{ $t('snakeCaseText') }}
{{ $t('pascalCaseText') }}
+
{{ $t('uniqueTranslation') }}
useHead with useLocaleHead { await page.click(`#set-locale-link-en`) expect(await getText(page, '#snake-case')).toEqual('About-this-site') expect(await getText(page, '#pascal-case')).toEqual('AboutThisSite') + expect(await getText(page, '#fallback-message')).toEqual('Unieke vertaling') await page.click(`#set-locale-link-fr`) expect(await getText(page, '#snake-case')).toEqual('À-propos-de-ce-site') expect(await getText(page, '#pascal-case')).toEqual('ÀProposDeCeSite') + expect(await getText(page, '#fallback-message')).toEqual('Unieke vertaling') }) }) diff --git a/src/gen.ts b/src/gen.ts index d368870f7..b919cffd4 100644 --- a/src/gen.ts +++ b/src/gen.ts @@ -202,7 +202,7 @@ export function generateLoaderOptions( const skipped = ['messages'] for (const [k, v] of Object.entries(cfg).filter(([k]) => !skipped.includes(k))) { - if(nuxtI18nOptions.vueI18n?.[k] === undefined) { + if(nuxtI18nOptions.vueI18n?.[k] === undefined || typeof nuxtI18nOptions.vueI18n?.[k] !== 'object') { nuxtI18nOptions.vueI18n[k] = v } else { deepCopy(v, nuxtI18nOptions.vueI18n[k]) diff --git a/test/__snapshots__/gen.test.ts.snap b/test/__snapshots__/gen.test.ts.snap index 75a9da63a..ea0189e94 100644 --- a/test/__snapshots__/gen.test.ts.snap +++ b/test/__snapshots__/gen.test.ts.snap @@ -214,7 +214,7 @@ export const resolveNuxtI18nOptions = async (context) => { const skipped = ['messages'] for (const [k, v] of Object.entries(cfg).filter(([k]) => !skipped.includes(k))) { - if(nuxtI18nOptions.vueI18n?.[k] === undefined) { + if(nuxtI18nOptions.vueI18n?.[k] === undefined || typeof nuxtI18nOptions.vueI18n?.[k] !== 'object') { nuxtI18nOptions.vueI18n[k] = v } else { deepCopy(v, nuxtI18nOptions.vueI18n[k])