nuxt-modules / i18n

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

Don't load default locale when differentDomain is true #3007

Open enwin opened 3 months ago

enwin commented 3 months ago

Describe the feature

The project I'm working on right now is a website with 4 different languages, each one tied to a domain. The same nuxt app is supposed to handle these 4 domains. Since each domain can only have one locale, I use the lazy option to only load the locale matching the domain. Unfortunately, the i18n module still tries to load the defaultLocale as well, and if it's not defined, I get a warning.

See this line for the part where the default locale is added to the list of locales: https://github.com/nuxt-modules/i18n/blob/ca3fe042351e64ce055436d5d89fcc061e9fd9f8/src/runtime/messages.ts#L66

Could it be possible to add a case like when lazy && options.strategy === "no_prefix" && options.differentDomains to not add the defaultLocale to the pool of locales to fetch?

I'm adding this as a feature request since my case can be a bit specific. Maybe there's more complexity to handle than just this simple if.

Thank you for taking the time to read this request. Let's talk!

Additional information

Final checks