nuxt-modules / i18n

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

Module automatically merges different iso for the same code to one in hreflang #2843

Closed GevaraDEV closed 6 months ago

GevaraDEV commented 6 months ago

Environment

any

Reproduction

locales: [
  { code: 'en', file: 'en.json', iso: 'en-US' },
  { code: 'pt', file: 'pt.json', iso: 'pt-BR' },
  { code: 'pt', file: 'pt.json', iso: 'pt-PT' },
  { code: 'pt', file: 'pt.json', iso: 'pt-MX' },
  { code: 'es', file: 'es.json', iso: 'es-ES' },
  { code: 'es', file: 'es.json', iso: 'es-MX' },
  { code: 'es', file: 'es.json', iso: 'es-BR' }
]

this generates hreflangs:

<link rel="alternate" href="localhost/en" hreflang="en" data-hid="7fcee50">
<link rel="alternate" href="localhost/en" hreflang="en-US" data-hid="1b5d3fd">
<link rel="alternate" href="localhost" hreflang="pt" data-hid="480869f">
<link rel="alternate" href="localhost" hreflang="pt-BR" data-hid="1177ed4">
<link rel="alternate" href="localhost/es" hreflang="es" data-hid="52a6c69">
<link rel="alternate" href="localhost/es" hreflang="es-ES" data-hid="47b09bd">
<link rel="alternate" href="localhost" hreflang="x-default" data-hid="6527e7a">

expected:

<link rel="alternate" href="localhost/en" hreflang="en" data-hid="7fcee50">
<link rel="alternate" href="localhost/en" hreflang="en-US" data-hid="1b5d3fd">
<link rel="alternate" href="localhost" hreflang="pt" data-hid="480869f">
<link rel="alternate" href="localhost" hreflang="pt-BR" data-hid="1177ed4">
<link rel="alternate" href="localhost" hreflang="pt-PT" data-hid="1177ed4">
<link rel="alternate" href="localhost" hreflang="pt-MX" data-hid="1177ed4">
<link rel="alternate" href="localhost/es" hreflang="es" data-hid="52a6c69">
<link rel="alternate" href="localhost/es" hreflang="es-ES" data-hid="47b09bd">
<link rel="alternate" href="localhost/es" hreflang="es-MX" data-hid="47b09bd">
<link rel="alternate" href="localhost/es" hreflang="es-BR" data-hid="47b09bd">
<link rel="alternate" href="localhost" hreflang="x-default" data-hid="6527e7a">

 

I read all docs, and didn't find any adequate solution for this, if I missed it up somewhere please share it, I'll really appreciate it

Describe the bug

Described in Description

Additional context

SEO, hreflang, multiple iso for the same locale

Logs

No response

BobbieGoede commented 6 months ago

Sorry for the late response, the code for each locale must be unique (see https://i18n.nuxtjs.org/docs/options/routing#locales) which is likely why you're running into this issue.

Closing this issue for now, if you run into any issues after changing the code properties to be unique, please let me comment with a minimal reproduction so I can take a closer look!