Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: extends / layers support for i18n.config.ts #1992

Closed
dargmuesli opened this issue Apr 13, 2023 · 6 comments · Fixed by #2025
Closed

fix: extends / layers support for i18n.config.ts #1992

dargmuesli opened this issue Apr 13, 2023 · 6 comments · Fixed by #2025
Assignees
Labels
config 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage v8

Comments

@dargmuesli
Copy link
Collaborator

dargmuesli commented Apr 13, 2023

Environment


  • Operating System: Linux
  • Node Version: v16.14.2
  • Nuxt Version: 3.4.1
  • Nitro Version: 2.3.3
  • Package Manager: npm@7.17.0
  • Builder: vite
  • User Config: modules, i18n
  • Runtime Modules: @nuxtjs/i18n@8.0.0-beta.11
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-akfq2d?file=playground%2Fnuxt.config.ts

Describe the bug

A project extending another one that uses the new i18n.config.ts errors as the file path is not resolved properly.

@kleinpetr
Copy link

kleinpetr commented May 5, 2023

Hi I am facing similar issue when I am trying to use resolver for langDir

  i18n: {
    lazy: true,
    strategy: 'no_prefix',
    langDir: resolve('./locales'),
    locales: [{ code: 'cs', file: 'cs.yml' }],
 }

When I try to use relative path

Since I am using layers, I cannot use just ./locales as it is described in the docs, because it seems that it resolves only the last cs.yml because the path is relative. So if I use /layer/locales/cs.yml with any translations here and then in the same layer try to use them. and in the project (last layer) create an empty locales/cs.yml it doesn't see the layer cs.yml messages.. when I check virtual files it looks like this

nuxtI18nOptions.locales = [
  Object({ code: 'cs', file: 'cs.yml', path: '/home/kleinpetr/Projects/.../apps/top-layer-app/locales/cs.yml' }),
  Object({ code: 'cs', file: 'cs.yml', path: '/home/kleinpetr/Projects/.../apps/top-layer-app/locales/cs.yml' }),
]

My folder structure (avoided generic files)

├── apps
│   └── top-layer-app
│       ├── locales (here I have just empty cs.yaml)
│       ├── nuxt.config.ts (i18n config as above)
├── layers
│   ├── components
│   │   └── test-components (in this layer I have messages and components which using them)
│   │       ├── locales
│   │       ├── nuxt.config.ts (i18n config as above)

So it seems that it creates two times the same path, relative path to the .nuxt/i18n.options.mjs I guess.

When I use resolver as I have to use for most other plugins, I am getting the same error which you are getting with your issue. That the import failed to resolve

@kazupon kazupon self-assigned this May 8, 2023
@kazupon kazupon reopened this May 8, 2023
Copy link
Collaborator

kazupon commented May 8, 2023

I've fixed this issue.
Please check edge channel 8.0.0-beta.11-28059008.d1499b6 version.
Thanks!

@dargmuesli
Copy link
Collaborator Author

Works for me! Thanks ❤️

@dargmuesli
Copy link
Collaborator Author

dargmuesli commented May 8, 2023

The build pipeline still shows some 500 errors, apparently connected to #2034 #2067. At least my laptop crashed while trying to check if there is a memory leak, which is a good indication 😉

@kleinpetr
Copy link

Where we can expect it in the stable release?

@dargmuesli
Copy link
Collaborator Author

This fix is part of beta.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage v8
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants