nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.76k stars 484 forks source link

Internal server error: Failed to resolve import "../i18n/locales/en-US.json" from ".nuxt/i18n.options.mjs" on following lazy-load translation guide #3213

Closed arun-mani-j closed 1 week ago

arun-mani-j commented 2 weeks ago

Environment

Reproduction

  1. Follow https://i18n.nuxtjs.org/docs/guide/lazy-load-translations as it is.
  2. On running with npm run dev, you will get error:
    Internal server error: Failed to resolve import "../i18n/locales/en-US.json" from ".nuxt/i18n.options.mjs". Does the file exist?
    Plugin: vite:import-analysis
    File: /home/path/to/project/.nuxt/i18n.options.mjs:11:66

Describe the bug

From what I can see, i18n expects the translation files to be under i18n/locales directory, so moving the files from i18n to i18n/locales fixes the issue.

So just updating the example directory structure is enough. If confirmed, I'm happy to PR the fix in docs 😅 .

Additional context

No response

Logs

userquin commented 2 weeks ago

PR welcome 🙏