nuxt-i18n not working in production
See original GitHub issueVersion
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:
- Created 3 years ago
- Comments:9
Top GitHub Comments
There is nothing like that right now but I’m glad it worked. 😃
The start command uses
nuxt.config.beta.js
configuration but that one doesn’t includenuxt-i18n
(it barely includes anything in fact). I guess your intention was to extend base config but you are not doing that.