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.

nuxt-i18n not working in production

See original GitHub issue

Version

nuxt-i18n: 6.12.2 nuxt: 2.12.2

Nuxt configuration

mode:

  • universal (pwa)
  • spa

Nuxt-i18n configuration

i18n: {
  strategy: 'prefix_except_default',
  defaultLocale: 'en',
  locales: [
    {
      code: 'en',
      iso: 'en-GB',
      name: 'English',
      file: 'en-GB.json',
    }, {
      code: 'de',
      iso: 'de-CH',
      name: 'Deutsch',
      file: 'de-CH.json',
    },
  ],
  vuex: {
    syncLocale: true,
    syncMessages: true,
  },
  // seo: true,
  lazy: true,
  langDir: 'assets/lang/',
},

Steps to reproduce

The problem is, that in a component, used in the layout (basically <layout><my-component></layout>) I use the this.$t('something') translation method and the this.$i18n. When running nuxt in development mode, everything works fine, but as soon as I run the application (NO CHANGES MADE) in production mode (nuxt build --pwa && npm run start) the app fails with following error: “o.localeRoute is not a function” (seems to be a problem in the renderer?). When having a look at the console, there is an error with following message: “Cannot read property ‘locales’ of undefined”. The property that is tried to be read is this.$i18n and in dev mode it has the locale property.

What is Expected?

To work same as in development mode (running nuxt)

What is actually happening?

The application doesn’t work anymore

PS: I had a look at following Issues/SOs: Why nuxt-i18n module doesn’t seem to be loaded? ( _vm.$t is not a function) #24 #43 #45 #58 #84 #137 #139 <- This one also happend to me, but as you see, i have my default locale set… #166 #173

I also asked my question on the community discord.

So I’m really desperate…

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
rchlcommented, Jun 5, 2020

There is nothing like that right now but I’m glad it worked. 😃

1reaction
rchlcommented, Jun 4, 2020

The start command uses nuxt.config.beta.js configuration but that one doesn’t include nuxt-i18n (it barely includes anything in fact). I guess your intention was to extend base config but you are not doing that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

nuxt-i18n not working in production · Issue #754 - GitHub
$i18n . When running nuxt in development mode, everything works fine, but as soon as I run the application (NO CHANGES MADE) in...
Read more >
Why nuxt-i18n module doesn't seem to be loaded? ( _vm.$t is ...
How does this answer resolve the issue? I actually have the same problem as in the question itself and there is nothing mentioned...
Read more >
[Solved]-nuxt i18n routing not working for sub pages-Vue.js
Below worked for me. I have a Nuxt pages structure like this. /pages/settings/car-form.vue. This is the Nuxt link to this sub-page with the...
Read more >
Different domains - i18n-module
Sometimes there's a need to change domains in different environments, e.g. staging and production. As nuxt.config.js is used at build time it would...
Read more >
Optimization - Vue I18n - Intlify
IF CSP is enabled, vue-i18n.esm-bundler.js would not work with compiler due to eval statements. These statements violate the default-src 'self' ...
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