-
-
Notifications
You must be signed in to change notification settings - Fork 515
Open
Labels
Description
Environment
- OS: Windows 11
- Node: 22.14.0
- Package manager: pnpm 10.11.0
- Nuxt: 4.0.2
- @nuxtjs/i18n: 10.2.1
- SSR: enabled
- Bundler: Vite (default)
- Build mode: development
- lazy translation loading: enabled
- strategy: "no_prefix"
- detectBrowserLanguage: enabled
Reproduction
nuxt.config.ts
export default defineNuxtConfig({
modules: ['@nuxtjs/i18n'],
i18n: {
defaultLocale: 'en',
detectBrowserLanguage: false,
locales: [
{ code: 'en', name: 'English', file: 'en.json' },
{ code: 'hr', name: 'Hrvatski', file: 'hr.json' },
],
},
});
app/layouts/default.vue:
const { locales } = useI18n();
console.log(locales.value);
output:
[
{ code: 'en', name: 'English', language: '' },
{ code: 'hr', name: 'Hrvatski', language: '' },
{ code: 'en', name: 'English', file: 'en.json' },
{ code: 'hr', name: 'Hrvatski', file: 'hr.json' }
]
Describe the bug
When using @nuxtjs/i18n version 10.2.1 with lazy-loaded translations and strategy: "no_prefix", locales.value contains duplicate locale entries.
Even though I define only two locales (en and hr), locales.value returns four:
two correct locales (with file)
two internally generated locales (without file)
This breaks language switchers and UI components that rely on locales.value.
Additional context
No response