skip to Main Content

I am having a problem with my Nuxt.js app.

I have installed nuxt-i18n 5.8.0, and made the following configuration in my nuxt.config.js file

[
  'nuxt-i18n',
  {
    locales: [
      {
        name: 'English',
        code: 'en',
        iso: 'en-US',
        file: 'en-US.js'
      },
      {
        name: 'Greek',
        code: 'el',
        iso: 'el-GR',
        file: 'el-GR.js'
      }
    ],
    lazy: true,
    langDir: 'lang/',
    defaultLocale: process.env.DEFAULT_LANG || 'en',
    baseUrl: process.env.BASE_URL,
    seo: false
  }
]

When I am in the default language, and clicking on a link in the page, the result is a ‘Page not found’ error. If I refresh the page, it works.

This happens in every page for every link with the default language.

If I use the secondary language, navigation works fine.

Any help??

Thnx!!

3

Answers


  1. i was has same issue to fix it add disable the detect browser language in :

      'nuxt-i18n',
      {
        ...
        detectBrowserLanguage: false
      }
    
    Login or Signup to reply.
  2. Please set fallbackLocale like below:

    // nuxt.config.js
    
    {
      modules: [
        [
          'nuxt-i18n',
          {
            locales: ['en', 'es'],
            defaultLocale: 'en',
            vueI18n: {
              fallbackLocale: 'en',
              messages: {
                en: {
                  greeting: 'Hello world!'
                },
                es: {
                  greeting: '¡Hola mundo!'
                }
              }
            }
          }
        ]
      ]
    }
    

    Please read link below for more information:

    https://github.com/nuxt-community/i18n-module

    Login or Signup to reply.
  3. add this line to i18n in your nuxt.config.js

    strategy: ‘prefix_and_default’

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search