nuxt-modules / i18n

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

Remove the auto-complete alternate langs #2784

Open luca-smartpricing opened 7 months ago

luca-smartpricing commented 7 months ago

Describe the feature

Hi! I've a website with the following langs it, de, en and all the path in the translated lang have it's own path /it/come-funziona /de/produkt /en/how-it-works

ok, that's easy, I have de following config:

defineI18nRoute({
  locales: ['it', 'de', 'en'],

  paths: {
    it: '/come-funziona',
    de: '/produkt',
    en: '/how-it-works'
  }
})

And if I have one less lang for a path it's something like:

defineI18nRoute({
  locales: ['it', 'en'],

  paths: {
    it: '/partner',
    en: '/partner'
  }
})

Ok, now the problem appear with dynamic pages. Because in the "blog" section not all articles are translated in all lang

defineI18nRoute({
  locales: ['it', 'en', 'de'],

  paths: {
    it: '/[blog]',
    en: '/[blog]',
    de: '/[blog]'
  }
})

// this specific article is not translated in `en`
setI18nParams({
    it: { blog: 'blog-1-it' },
    de: { blog: 'blog-1-de' },
})

So why is the following path added by default /en/blog-1-it? I think this behavior is similar to a bug. I don't want that to ever happen. Not even on non-dynamic pages I prefer something like

defineI18nRoute({
  paths: {
    it: '/partner',
    en: '/partner'
  }
})

without having to specify the list of languages.

By default i have 3 langs, yes. And lang switcher always show 3 langs but if I don't set one it means that it doesn't exist, it makes no sense that only the /en prefix is changed and a route that doesn't exist is created. This compromises the entire management of rel=alternate and SEO.

I kindly ask you to give an answer to this question and look for a solution together because I think that the use of i18n is really complex if brought back to real management situations with a CMS. After almost a year of use there are still many problems related to SEO, changing languages, creating sitemaps, dynamic pages, etc.

Thank you very much

Additional information

Final checks

BobbieGoede commented 7 months ago

So why is the following path added by default /en/blog-1-it? I think this behavior is similar to a bug. I don't want that to ever happen. Not even on non-dynamic pages

By default i have 3 langs, yes. And lang switcher always show 3 langs but if I don't set one it means that it doesn't exist, it makes no sense that only the /en prefix is changed and a route that doesn't exist is created. This compromises the entire management of rel=alternate and SEO.

The reason behind this is probably similar to route and page generation, it is by default assumed that you are serving a page in each configured language. As you have noticed in #2782, opinions differ on what should happen if a param translation is not provided, I agree it's preferable to skip tags if no translation has been provided.

I kindly ask you to give an answer to this question and look for a solution together because I think that the use of i18n is really complex if brought back to real management situations with a CMS. After almost a year of use there are still many problems related to SEO, changing languages, creating sitemaps, dynamic pages, etc.

This module is maintained by only a few people who work on this in their spare time, your suggestions, discussions and issues are appreciated, and at the end of the day we can only do so much so contributions are also very much welcome.

If I have time I'll see if I can come up with a solution for this issue, I'll take what's discussed in #2782 into account.