i18n icon indicating copy to clipboard operation
i18n copied to clipboard

Default locale configured in `i18n.config` not used as project `defaultLocale`

Open AliakseiMatsuk opened this issue 1 year ago • 7 comments

Environment

Reproduction

i18n.config.ts configuration

Снимок экрана 2024-04-17 в 16 03 12

nuxt.config.ts configuration

Снимок экрана 2024-04-17 в 16 03 32

Describe the bug

After updating to version 8.3.0, when the page is reloaded, plugin always sets the default locale, cookie i18n_redirected are also overwritten

Additional context

With version 8.1.1 everything works correctly

Logs

No response

AliakseiMatsuk avatar Apr 17 '24 14:04 AliakseiMatsuk

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 Reproduction starter (v8 and higher) 👉 Reproduction starter (edge)

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

github-actions[bot] avatar Apr 17 '24 17:04 github-actions[bot]

Hi @BobbieGoede. I have made a minimal reproduction at https://github.com/MikeBellika/nuxti18nrepro/. Let me know if there's more I can do to help. Note that the bug doesn't seem to reproduce on stackblitz. I had to run it on my machine to get it to fail.

PS. As @AliakseiMatsuk said 3.1.1 seems to work and 3.2.0 also works

MikeBellika avatar May 17 '24 08:05 MikeBellika

Started a new project still not working

botafi avatar May 31 '24 17:05 botafi

I can confirm that it is not working on 8.3.0 and on 8.1.1 it works just fine, this issue took me like 2 hours to solve before I found this.

CoconutTheSlayer avatar May 31 '24 17:05 CoconutTheSlayer

I think I've found a fix. Setting the locales option in nuxt.config seems to be required. I've made a branch on my reproduction repo, where you can see the fix: https://github.com/MikeBellika/nuxti18nrepro/blob/3d4615be16322a356e8d6f86fae5e1e4d8682338/nuxt.config.ts#L8

export default defineNuxtConfig({
  devtools: { enabled: true },
  modules: ["@nuxtjs/i18n"],
  i18n: {
    vueI18n: "./i18n.config.ts",
    strategy: "no_prefix",
    locales: ["en", "fr"], // <--- Important
  },
});

I think it's probably caused by this line: https://github.com/nuxt-modules/i18n/blob/622369645a951f7dc924bfad0d7eb57e145844f3/src/runtime/internal.ts#L132

There's mention in the docs about setting the locales option, but it's "hidden" under link localizing, so I missed it. There's also no mention in the changelog that I can see.

@BobbieGoede is this a bug or a docs issue? And let me know if there's something I can do :)

MikeBellika avatar Jun 06 '24 07:06 MikeBellika

@MikeBellika Thanks you so much, I take hours to try to fix this. It's not clear in the docs that locales property should be only lie on nuxt.config and not i18n.config. I configured i18n module only in i18n.config and don't put anything in nuxt.config... It could help to improve docs with a dedicated page for no_prefix strategy.

Reeska avatar Oct 09 '24 08:10 Reeska