nuxt-modules / i18n

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

Route is break when nuxt.config is updated #259

Closed orblazer closed 5 years ago

orblazer commented 5 years ago

Version

v5.8.5

Reproduction link

Not really needed

Steps to reproduce

  1. Install nuxt-i18n
  2. Create routes with like config :
    [
    'nuxt-i18n',
    {
    locales: [
    { code: 'en', name: 'English', iso: 'en-US', file: 'en.js' },
    { code: 'fr', name: 'Français', iso: 'fr-FR', file: 'fr.js' }
    ],
    defaultLocale: 'en',
    lazy: true,
    langDir: 'locale/',
    vueI18n: {
    fallbackLocale: 'en',
    dateTimeFormats: {
    fr: {
      long: {
        year: 'numeric',
        month: 'long',
        day: 'numeric',
        weekday: 'long'
      },
      timeShort: {
        year: 'numeric',
        month: 'numeric',
        day: 'numeric',
        hour: 'numeric',
        minute: 'numeric'
      },
      timeLong: {
        year: 'numeric',
        month: 'long',
        day: 'numeric',
        weekday: 'long',
        hour: 'numeric',
        minute: 'numeric'
      }
    },
    en: {
      long: {
        year: 'numeric',
        month: 'long',
        day: 'numeric',
        weekday: 'long'
      },
      timeShort: {
        year: 'numeric',
        month: 'numeric',
        day: 'numeric',
        hour: 'numeric',
        minute: 'numeric'
      },
      timeLong: {
        year: 'numeric',
        month: 'long',
        day: 'numeric',
        weekday: 'long',
        hour: 'numeric',
        minute: 'numeric'
      }
    }
    },
    detectBrowserLanguage: {
    useCookie: true,
    alwaysRedirect: true,
    fallbackLocale: 'en'
    },
    onLanguageSwitched: (previous, current) => {
    if (process.client) {
      cookie.serialize('i18n_redirected', current, {
        expires: new Date(new Date() + 365),
        path: '/'
      })
    }
    }
    ]
  3. Update nuxt.config.js

What is expected ?

Just update

What is actually happening?

When nuxt.config.js is updated we have

 WARN  [vue-router] Route with name 'index___en' does not exist                                                               11:26:56
 WARN  [vue-router] Route with name 'index___fr' does not exist                                                               11:26:56
This bug report is available on Nuxt community (#c220)
dappiu commented 5 years ago

I just experienced a problem that may be related, but seems that your proposed fix it does not solve that too: the strategy: 'prefix_except_default' does not work anymore and prefixes also the defaultLocale, breaking nuxt-link references

orblazer commented 5 years ago

@dappiu Hello, i have try and not this is work, if the refresh the page this is redirect because i18n_redirected is present and is not update when switch locale (i go fix that today)

robinscholz commented 5 years ago

Experiencing the same issue

atinux commented 5 years ago

Should this issue be closed since https://github.com/nuxt-community/nuxt-i18n/pull/291 is merged?

orblazer commented 5 years ago

@Atinux probably yes, i can't try beacause i no longer use nuxt for now