nuxt-modules / i18n

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

Support multiple domains in local options #1100

Open jinevo opened 3 years ago

jinevo commented 3 years ago

Problem

Currently the only way to support multiple domains for one code is to declare each domain separately. At the first sight, it could be managed by env variables but it is useful when we want to progressively migrate a website to nuxt.

{
  locales: [
    {
      code: 'fr',
      domain: 'domain.fr',
      file: 'fr.js'
    },
    {
      code: 'fr',
      domain: 'fr.nuxtprod-domain.com',
      file: 'fr.js'
    },
    {
      code: 'fr',
      domain: 'fr.nuxtuat-domain.com',
      file: 'fr.js'
    },
    {
      code: 'en',
      domain: 'domain.com',
      file: 'en.js'
    },
    {
      code: 'en',
      domain: 'en.nuxtprod-domain.com',
      file: 'en.js'
    },
    {
      code: 'en',
      domain: 'en.nuxtuat-domain.com',
      file: 'en.js'
    },
   // and so on
  ],
  differentDomains: true
}

Besides, this implementation generates duplicated routes definition warnings in the console / terminal from vue-router WARN [vue-router] Duplicate named routes definition: { name: "index___en", path: "" }

Solution

The solution would be to support an array of domains in the domain value

{
  locales: [
    {
      code: 'fr',
      domain: ['domain.fr', 'fr.nuxtprod-domain.com', 'fr.nuxtuat-domain.com'],
      file: 'fr.js'
    },
    {
      code: 'en',
      domain: ['domain.com', 'en.nuxtprod-domain.com', 'en.nuxtuat-domain.com'],
      file: 'en.js'
    },
   // and so on
  ],
  differentDomains: true
}
stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

larbijirari commented 1 year ago

hello, i'm facing the same situation, any news about this feature ?