\n\n It calls twice `loadMessages` first time from init, and second after \"locale-changing\" middleware.\n\n\u003Cimg width=\"1591\" height=\"419\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/956c305d-57e9-4a71-a3b6-5e2231a460df\" />\n\nLog from middleware handler\n\n\u003Cimg width=\"1080\" height=\"934\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/228c3154-f653-4190-b9a4-7ce6c197b00d\" />\n\nI faced this problem on big project, i thought maybe i have problems in router or something else, but used it tiny one to be sure\nTried to add and remove lazy: true, detectBrowserLanguage: false also tried.\n\n**Project structure, no custom routing**\n\u003Cimg width=\"1137\" height=\"991\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/9b9385cd-713e-4801-af61-6f8be38c73f1\" />\n\n### Additional context\n\n_No response_\n\n### Logs\n\n```shell\n\n```",[3225],{"name":3173,"color":3174},3813,"closed","Duplicate request on client for messages","2025-09-11T15:30:00Z","https://github.com/nuxt-modules/i18n/issues/3813",0.6125227,{"description":3233,"labels":3234,"number":3238,"owner":3176,"repository":3177,"state":3227,"title":3239,"updated_at":3240,"url":3241,"score":3242},"### Environment\n\nOperating System: Linux\nNode Version: v22.11.0\n\"dependencies\": {\n \"@element-plus/icons-vue\": \"^2.3.1\",\n \"@nuxtjs/i18n\": \"^9.5.3\",\n \"@pinia/nuxt\": \"^0.10.1\",\n \"nuxt\": \"^3.16.2\",\n \"pinia\": \"^3.0.1\",\n \"vue\": \"^3.5.13\",\n \"vue-router\": \"^4.5.0\"\n },\n \"devDependencies\": {\n \"@antfu/eslint-config\": \"^4.11.0\",\n \"@element-plus/nuxt\": \"^1.1.1\",\n \"element-plus\": \"^2.9.7\",\n \"eslint\": \"^9.24.0\",\n \"sass\": \"^1.86.3\",\n \"sass-embedded\": \"^1.86.3\",\n \"typescript\": \"^5.8.3\"\n }\n\n### Reproduction\n\n低版本没有这个问题,打印值,服务端一次,客户端一次\n\n\n此次版本:\n\"nuxt\": \"^3.16.2\",\n\"@nuxtjs/i18n\": \"^9.5.3\",\n\n\n目录结构:根目录下 i18n -> locales -> locale.ts\nnuxt.config.ts文件\n\nmodules: [\n '@element-plus/nuxt',\n '@nuxtjs/i18n',\n ],\n i18n: {\n /* 较新版本的 @nuxtjs/i18n 模块中出现警告, 特别是与nuxt3.16.x一起使用 \n * bundle.optimizeTranslationDirective is enabled by default, we recommend disabling this feature as it causes issues and will be deprecated in v10.\n * bundle.optimizeTranslationDirective 功能在未来的 v10 版本中将被弃用,并且开发团队建议禁用它,因为它可能导致问题。\n * 明确设置此选项后,警告会消失,并且应用程序将更好地适应未来的 i18n 模块更新。\n * 如添加之后,警告未消失 1. 比对版本是否兼容 2. 缓存问题,nuxt使用了旧的缓存配置 npx nuxi cleanup\n */\n bundle: {\n optimizeTranslationDirective: false // 明确禁用此功能\n },\n // Module Options\n strategy: 'no_prefix', // 不为路由添加区域前缀\n defaultLocale: 'en', // 默认语种\n detectBrowserLanguage: false, // 禁用浏览器语言检测功能\n lazy: true,\n locales: [\n {\n code: 'en',\n file: 'locale.ts',\n },\n ],\n compilation: {\n strictMessage: false, // 允许message中包含html\n },\n },\n\n### Describe the bug\n\nexport default defineI18nLocale(async (locale) => {\n console.log(locale)\n})\n打印出来,打印了4次,服务端2次,客户端2次\n \n\n\n### Additional context\n\n_No response_\n\n### Logs\n\n```shell\n\n```",[3235],{"name":3236,"color":3237},"scope: dynamic resources","38FB12",3538,"defineI18nLocale Repeated call problem, Server twice, client twice","2025-06-29T18:38:45Z","https://github.com/nuxt-modules/i18n/issues/3538",0.64518875,{"description":3244,"labels":3245,"number":3252,"owner":3176,"repository":3177,"state":3227,"title":3253,"updated_at":3254,"url":3255,"score":3256},"### Environment\n\n- Nuxt version: 3.17.4\n- @nuxtjs/i18n version: 10.0.0-beta-7\n- Deployment target: Static site (nuxi generate)\n- Works fine in SSR build (nuxi build)\n- Node version: 22\n\n### Reproduction\n\nhttps://codesandbox.io/p/devbox/prod-https-6gz2f5\n\n- run `pnpm generate` command and check output folder. there is no i18n folder. \n- run `pnpm start` to run generate build. open browser console. you'll see `Failed to load messages for locale en FetchError: [GET] \"/_i18n/en/messages.json\":`\n\n### Describe the bug\n\nWhen generating a static site using `nuxi generate`, I get the following error in the console when loading the site:\n```\nFailed to load messages for locale en FetchError: [GET] \"/_i18n/en/messages.json\": 404 Not Found\n```\n\nThe same Nuxt app works fine with nuxtjs/i18n v9\n\nSetting `ssr: true` works fine for both build & generate \n\n### Additional context\n\nHere’s part of my nuxt.config.ts:\n```\n{\n defaultLocale: 'en',\n debug: import.meta.env.DEV,\n locales: [\n {\n code: 'en',\n language: 'en-US',\n file: 'en.json',\n name: 'English',\n },\n {\n code: 'es',\n file: 'es.json',\n name: 'Spanish',\n },\n {\n code: 'tl',\n file: 'tl.json',\n name: 'Tagalog (Filipino)',\n },\n ],\n strategy: 'no_prefix',\n detectBrowserLanguage: {\n useCookie: true,\n cookieKey: 'dmc.locale',\n redirectOn: 'root',\n },\n}\n```\n\n### Logs\n\n```shell\nTkPgtAp_.js:9 Failed to load messages for locale en FetchError: [GET] \"/_i18n/en/messages.json\": 404 Not Found\n at async s (N_fP37pm.js:19:23784)\n at async Object.loadLocaleMessages (N_fP37pm.js:53:9792)\n at async B1 (N_fP37pm.js:53:11552)\n at async setup (N_fP37pm.js:67:48664)\n at async t$ (N_fP37pm.js:19:30748)\n at async i (N_fP37pm.js:19:31273)\n at async N_fP37pm.js:19:31213\n at async Promise.all (:8080/index 5)\n at async N_fP37pm.js:19:31122\n at async i (N_fP37pm.js:19:31273)\n at async n$ (N_fP37pm.js:19:31324)\n at async Qk (N_fP37pm.js:1100:1993)\n```",[3246,3249],{"name":3247,"color":3248},"scope: ssg","85eac7",{"name":3250,"color":3251},"scope: ssr","0052cc",3645,"Failed to load messages for locale only in static site generated with nuxi generate (404 on /_i18n/en/messages.json)","2025-05-26T18:06:23Z","https://github.com/nuxt-modules/i18n/issues/3645",0.64962506,{"description":3258,"labels":3259,"number":3263,"owner":3176,"repository":3177,"state":3227,"title":3264,"updated_at":3265,"url":3266,"score":3267},"### Environment\r\n\r\n------------------------------\r\n- Operating System: Linux\r\n- Node Version: v18.16.0\r\n- Nuxt Version: 3.7.1\r\n- CLI Version: 3.7.3\r\n- Nitro Version: 2.6.2\r\n- Package Manager: pnpm@8.6.12\r\n- Builder: -\r\n- User Config: extends, telemetry, ssr, fontMetrics, nitro, routeRules, runtimeConfig, build, modules, delayHydration, image, components, bugsnag, devtools, i18n, experimental, pwa, app, dnGraphqlClient, vite, plugins\r\n- Runtime Modules: @nuxtjs/fontaine@0.4.1, @pinia/nuxt@0.4.11, @nuxt/devtools@0.8.2, @vite-pwa/nuxt@0.1.0, nuxt-bugsnag@7.0.0, @digitalnatives/css-variables/nuxt@5.1.3, @digitalnatives/graphql-client@4.0.3, @nuxtjs/i18n@8.0.0-rc.4, @nuxt/image@1.0.0-rc.1, nuxt-delay-hydration@1.2.1, @digitalnatives/composables@2.0.1\r\n- Build Modules: -\r\n------------------------------\r\n\r\n### Reproduction\r\n\r\nA naïve reproduction is the following:\r\n\r\n```js\r\nconst route = useRoute(); \r\nconst locale = useLocale();\r\n\r\n// On switch, this will first log the NEW locale with the OLD path, then it will trigger a second time, logging the NEW locale with the NEW path\r\nwatchEffect(() => {\r\n console.log(route.fullPath);\r\n console.log(locale);\r\n});\r\n```\r\n\r\nAdd it to a global component in the layout that doesn't get mounted/umounted on URI change.\r\n\r\n\r\n\r\n### Describe the bug\r\n\r\nWhen using prefixed routes and a language switcher as described in the docs, it seems the locale changes before the route does.\r\n\r\nWhen watching the locale with `useAsyncData()` or `useLazyAsyncData()` this will cause the results of this call to be associated with the wrong URL/path, which then has a side-effect of refetching API data which was already pre-rendered in Nuxt static mode. Therefore, the pre-rendered payload is NOT used in this pattern, even though it should.\r\n\r\nI've also seen this lead to data mismatching to the wrong paths, but this is a bit harder to create a reproduction for.\r\n\r\n### Additional context\r\n\r\nMy current workaround is this;\r\n\r\ncomposable:\r\n```js\r\nexport const useVariables = () => {\r\n const route = useRoute();\r\n const { $i18n }: any = useNuxtApp();\r\n // Don't automatically update the site and url to ensure they both change at the same time\r\n variables.uri = toValue(route.path);\r\n variables.lang = toValue($i18n?.localeProperties)?.apiLanguageHandle;\r\n\r\n // Update variables manually when the route changes, at this point both the locale AND the URI are correct.\r\n watch(() => route.path, () => {\r\n variables.uri = toValue(route.path);\r\n variables.lang = toValue($i18n?.localeProperties)?.apiLanguageHandle;\r\n });\r\n return { variables };\r\n});\r\n```\r\n\r\nthen:\r\n\r\n```js\r\nconst { variables } = useVariables();\r\nuseAsyncData(() => { console.log('trigger!') } , { watch: [ variables ] });\r\n```\r\n\r\n\r\nPerhaps it would be possible to inject the locale & locale properties into the localized route meta? That way we could just watch the route and apply the language from that.\r\n\r\nRelates to #2278 \r\n\r\n### Logs\r\n\r\n_No response_",[3260],{"name":3261,"color":3262},"switch locale","D2FCC6",2377,"`locale` changes BEFORE the route path does, which causes issues with (static) `asyncData`-payloads","2025-05-16T11:44:11Z","https://github.com/nuxt-modules/i18n/issues/2377",0.66013354,{"description":3269,"labels":3270,"number":3271,"owner":3176,"repository":3177,"state":3227,"title":3272,"updated_at":3273,"url":3274,"score":3275},"## Bug Report\n\n### Describe the bug\nThe base locale file (ar.json) is completely ignored by @nuxtjs/i18n in Nuxt 4, while market-specific locale files (ar-MA.json, ar-SA.json, ar-AE.json) load correctly. This results in a broken fallback mechanism where translations that should fall back to the base locale display as literal translation keys.\n\n### Environment\n- **Nuxt**: 4.1.2\n- **@nuxtjs/i18n**: 10.1.0\n- **Node**: Latest LTS\n- **Package Manager**: pnpm\n- **OS**: macOS\n- **Browser**: All browsers (SSR issue)\n\n### Configuration\n\n**nuxt.config.ts (i18n section)**:\n```typescript\ni18n: {\n vueI18n: './i18n.config.ts',\n lazy: true,\n langDir: 'locales',\n defaultLocale: 'ar-ma',\n strategy: 'prefix',\n locales: [\n {\n code: 'ar',\n iso: 'ar',\n language: 'ar',\n file: 'ar.json',\n name: 'العربية',\n dir: 'rtl'\n },\n {\n code: 'ar-ma',\n iso: 'ar-MA',\n language: 'ar-MA',\n file: 'ar-MA.json',\n name: 'العربية',\n dir: 'rtl'\n },\n // ... other market locales (ar-sa, ar-ae)\n ]\n}\n```\n\n**i18n.config.ts**:\n```typescript\nexport default defineI18nConfig(() => ({\n legacy: false,\n fallbackLocale: 'ar',\n missingWarn: false,\n fallbackWarn: false\n}))\n```\n\n**File structure**:\n```\nlocales/\n├── ar.json (7KB - comprehensive base translations)\n├── ar-MA.json (12KB - Morocco-specific translations)\n├── ar-SA.json (1KB - Saudi Arabia-specific translations)\n└── ar-AE.json (1KB - UAE-specific translations)\n```\n\n### Expected Behavior\n1. When accessing `/ar-ma/` route, ar-MA.json should load first\n2. For missing keys in ar-MA.json, the system should fall back to ar.json\n3. All translation keys should resolve to actual translated text\n\n### Actual Behavior\n1. ✅ ar-MA.json loads correctly and provides market-specific translations\n2. ❌ ar.json is completely ignored and never loads\n3. ❌ Missing keys display as literal translation keys (e.g., \"nav.mainMenu\" instead of translated text)\n\n### Reproduction Steps\n1. Set up Nuxt 4 project with @nuxtjs/i18n v10.1.0\n2. Configure multiple locales with a base locale and market-specific locales\n3. Use `lazy: true` and `prefix` strategy\n4. Set `defaultLocale` to a market-specific locale (e.g., 'ar-ma')\n5. Set `fallbackLocale` to base locale (e.g., 'ar')\n6. Create comprehensive base locale file and minimal market-specific files\n7. Access market-specific route (e.g., `/ar-ma/`)\n8. Observe that base locale translations never load\n\n### Console Output\nThe server consistently shows warnings for ALL keys that should be in the base locale:\n```\nWARN [intlify] Not found 'nav.mainMenu' key in 'ar' locale messages.\nWARN [intlify] Not found 'search.title' key in 'ar' locale messages.\nWARN [intlify] Not found 'landing.hero.startConsultation' key in 'ar' locale messages.\n[... hundreds of similar warnings]\n```\n\n### Debugging Attempts\n1. ✅ Verified ar.json is valid JSON with correct structure\n2. ✅ Verified ar.json contains all the keys being requested\n3. ✅ Cleared .nuxt, .output, and node_modules/.cache multiple times\n4. ✅ Restarted dev server completely\n5. ✅ Added debug text to ar.json - changes are never reflected in output\n6. ✅ Confirmed file permissions and encoding are correct\n7. ❌ Base locale file is never loaded by the i18n system\n\n### Key Findings\n- **Market-specific locales work perfectly**: ar-MA.json loads and displays Morocco-specific translations\n- **Fallback logic works**: The system attempts to fall back to 'ar' locale (as shown in console warnings)\n- **Base locale completely ignored**: Despite being properly configured and containing valid translations, ar.json is never loaded\n- **File is valid**: ar.json parses correctly with node -e \"JSON.parse(...)\"\n\n### Minimal Reproduction\nThis appears to be related to the combination of:\n- Nuxt 4.1.2\n- @nuxtjs/i18n 10.1.0 \n- `lazy: true` configuration\n- `prefix` strategy\n- `defaultLocale` set to non-base locale\n- Multiple market-specific locales with base locale fallback\n\n### Impact\nThis breaks the core fallback functionality of internationalization, causing numerous UI elements to display as literal translation keys instead of translated text, significantly degrading user experience.\n\n### Workaround\nCurrently, the only workaround is to duplicate all base translations into each market-specific locale file, which defeats the purpose of having a fallback mechanism and creates maintenance overhead.",[],3824,"Base locale file not loading in Nuxt 4 with @nuxtjs/i18n v10.1.0 - Fallback mechanism partially broken","2025-10-08T13:11:01Z","https://github.com/nuxt-modules/i18n/issues/3824",0.6668981,["Reactive",3277],{},["Set"],["ShallowReactive",3280],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$fugQHQqm8lTfPg2vOMGFqx_mZKtEOveOsD3_hwSz0B_g":-1},"/nuxt-modules/i18n/3773"]