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

Chosen locale is loading a different locale file that is set in object #2803

Closed
nford88 opened this issue Feb 16, 2024 · 4 comments
Closed
Labels
bug 🐛 ❗ p4-important Priority 4: bugs that violate documented behavior, or significantly impact perf v8

Comments

@nford88
Copy link

nford88 commented Feb 16, 2024

Environment


  • Operating System: Linux
  • Node Version: v20.10.0
  • Nuxt Version: 3.10.2
  • CLI Version: 3.10.1
  • Nitro Version: 2.8.1
  • Package Manager: npm@10.2.3
  • Builder: -
  • User Config: devtools, runtimeConfig, typescript, ssr, devServer, app, css, components, build, vite, modules, gtm, i18n, pinia, alias, hooks, plugins
  • Runtime Modules: @pinia/nuxt@0.5.1, @nuxtjs/i18n@8.1.1, @zadigetvoltaire/nuxt-gtm@0.0.13
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/nuxt-starter-ymkpzl?file=nuxt.config.ts

Describe the bug

My site have multiple locales which are language and country specific. For this example, I create one main language file (de.json) which majority of translations, I then create one specific country file (de-CH.json). Both are inserted as locale objects below.

locales: [
      {
        code: 'de-CH',
        iso: 'de-CH',
        files: ['de.json', 'de-CH.json'],
      },
      {
        code: 'de-DE',
        iso: 'de-DE',
        file: 'de.json',
      },
    ]

However, the 'de-DE' locale is accessing the translations from 'de-CH.json' file when that locale should only being 'de.json' file.

There seems to be an issue with the spreading of the locale objects json files and both locales are receiving the same translations object when they should have their own be separate objects.

Additional context

No response

Logs

No response

@nford88 nford88 changed the title Chosen locale is loading a different locale file that was is set in object Chosen locale is loading a different locale file that is set in object Feb 16, 2024
@BobbieGoede BobbieGoede added v8 ❗ p4-important Priority 4: bugs that violate documented behavior, or significantly impact perf bug 🐛 and removed pending triage labels Feb 16, 2024
@nford88
Copy link
Author

nford88 commented Feb 22, 2024

hey @BobbieGoede do you know if there is any room on the roadmap to examine this? I can try and find some time to help debug if that's any use.

It's a blocker for myself to move an application from Nuct 2 to Nuxt 3 as we are mid migration. If its going to be a while I might try and find an alternative temporary solution (manually building one json per country) so I can keep on working through. Many thanks!

@BobbieGoede
Copy link
Collaborator

@nford88
Sorry I didn't get around to fixing this yet, it seems something is going wrong with caching and I think the imported de.json file is being mutated.

I do have a workaround using dynamic locale files which is less performant but should unblock your migration while this issue exists. I have updated your reproduction to demonstrate the workaround here.

@nford88
Copy link
Author

nford88 commented Feb 28, 2024

I implemented your workaround now. I have about 150 translations in the main language files and approximately 20-30 in the locale country files. Not seeing too much of a performant dip. Will see how it goes. Thanks!

@BobbieGoede
Copy link
Collaborator

This will be resolved with #3137 since I've fixed the issue upstream! Here's an updated reproduction with using a preview release https://stackblitz.com/edit/nuxt-starter-mwtgfw?file=package.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 ❗ p4-important Priority 4: bugs that violate documented behavior, or significantly impact perf v8
Projects
None yet
Development

No branches or pull requests

2 participants