nuxt-modules / i18n

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

Possible regression with custom domains and localized paths #3058

Closed darioielardi closed 3 months ago

darioielardi commented 3 months ago

Environment

Reproduction

https://github.com/darioielardi/nuxt-i18n-play

On main you'll find @nuxtjs/i18n@^8.3.3 installed. To test with @nuxtjs/i18n@8.2.0 switch to the nuxt-i18n-v8.2 branch.

To test different domains you need to add this to your hosts file:

0.0.0.0 nuxt-i18n-play.en
0.0.0.0 nuxt-i18n-play.it
0.0.0.0 nuxt-i18n-play.fr

Describe the bug

My use case is an application with a different domain for each locale, and localized paths. For example:

Until v8.2.0, I would set differentDomains: true, set up the locales with relative domains, add localized paths with customRoutes: 'config' + pages config, and it worked perfectly.

From this PR (as someone noted in the comment) that doesn't work anymore, as it will add a locale prefix to every path, which is of course redundant and undesired in my case.

Adding strategy: 'no_prefix' doesn't work with custom paths (as it's stated in the docs), but in the case of different domains I think it's reasonable to expect that the prefix is omitted anyway (as it was in v8.2.0), or at least to have some way to configure that.

Is the new behavior unexpected (and therefore a bug) or I'm missing something? Let me know if you need any more context, and thanks for your great work!

Additional context

Related issue: https://github.com/nuxt-modules/i18n/issues/2729

Logs

No response

BobbieGoede commented 3 months ago

Thank you for reporting and providing a good/complete description with reproduction! 🙏

Is the new behavior unexpected (and therefore a bug) or I'm missing something?

It seems like we didn't have tests for the previous behavior and the functionality got broken since it depended on the exclusion of strategy: 'no_prefix' which is a bit confusing (I wasn't aware of this detail).

I'll see if I can figure out a fix soon, hopefully this week.