question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Different domains with multiple languages each

See original GitHub issue

I am not a 100% sure if this really isn’t possible yet, but it seems like it isn’t. We have multiple TLD’s and one of them (.ch) needs to have two languages which should result in the following domain/path/locale combinations:

  • weekend4two.ch de-CH
  • weekend4two.ch/fr fr-CH
  • weekend4two.de de-DE
  • weekend4two.at de-AT
  • weekend4two.fr/fr OR weekend4two.fr fr-FR (We do not really care since the .fr TLD does only need one language)

I’ve tried a few configs to achieve what I need but had no success. This one was the closest:

/* nuxt.config.js */
...
i18n: {
  differentDomains: true,
  strategy: 'prefix_except_default',
  locales: [
    {
      code: 'de-CH',
      iso: 'de-CH',
      domain: 'weekend4two.ch',
    },
    {
      code: 'fr-CH',
      iso: 'fr-CH',
      domain: 'weekend4two.ch',
    },
    {
      code: 'fr-FR',
      iso: 'fr-FR',
      domain: 'weekend4two.fr',
    },
    {
      code: 'de-DE',
      iso: 'de-DE',
      domain: 'weekend4two.de',
    },
    {
      code: 'de-AT',
      iso: 'de-AT',
      domain: 'weekend4two.at',
    },
  ],
}
...
  
/* index.vue */
...
<script>
export default {
  nuxtI18n: {
    paths: {
      de: '/',
      fr: '/fr',
      'fr-CH': '/fr',
    },
  },
}
</script>
...

The seems to result in a working solution where all the domains/path exist. But when going to weekend4two.ch/fr, the locale is set to de-CH. Whatever I do, it takes the locale of the first entry with the same domain.

Describe the solution you’d like

It would be cool if the locales config in nuxt.config.js could be extended with a prefix property like this:

/* nuxt.config.js */
locales: [
  {
    code: 'de-CH',
    iso: 'de-CH',
    domain: 'weekend4two.ch',
    prefix: '', /* could be removed too */
  },
  {
    code: 'fr-CH',
    iso: 'fr-CH',
    domain: 'weekend4two.ch',
    prefix: '/fr',
  },
  ...
]

Describe alternatives you’ve considered

I am open to all alternatives. It may be possible that it even is possible in a way I haven’t figured out yet. I am new to NUXT.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:6
  • Comments:18

github_iconTop GitHub Comments

6reactions
marcmalereicommented, Oct 21, 2021

I face the same requirements. Would be great if the solution provide by @lfglopes could be merged.

5reactions
nikolashaagcommented, Nov 12, 2021

I have the same requirements for a page that has multiple locales on each domain. This seems like a common usecase, so would be great if this can get merged!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multilingual websites: single or multiple domains?
If you're planning a multilingual website, it'll pay to think carefully about whether to have one or multiple domains. This article offers guidance...
Read more >
Multilingual Websites: Single domain vs multiple domains?
In the majority of cases, a multilingual website with a single domain (example.com/fr or example.com/es) will provide a greater SEO opportunity ...
Read more >
Three Domain Strategies for your Multilingual Website ...
For every language subdomain you can create a different layout or offer different content.
Read more >
Should You Use Single or Multiple Domains for a ...
When you are using just one domain, the website developer may offer you different plugins to support multiple languages. In this case, every...
Read more >
Managing multi-regional and multilingual sites
Google recommends using different URLs for each language version of a page rather than using cookies or browser settings to adjust the content...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found