vuetify-nuxt-module icon indicating copy to clipboard operation
vuetify-nuxt-module copied to clipboard

i18n key not found in locale messages

Open AasmundN opened this issue 2 years ago • 7 comments

After following documentation for basic setup of i18n with lazy loading of locales from files, I get this error on the initial render:

[intlify] Not found 'welcome' key in 'en' locale messages.

Reproduction:

https://stackblitz.com/edit/github-6zjd6y?file=app.vue,nuxt.config.ts,package.json,lang%2Fen-US.json,i18n.config.ts

Is this a bug, or am I just doing something wrong? I have checked the playground, and things seem to be working there, but I can't figure out what is different there vs my code.

AasmundN avatar Aug 06 '23 22:08 AasmundN

To access message using Vuetify $t you need to prefix the key with $vuetify.: $t('$vuetify.welcome')

userquin avatar Aug 07 '23 08:08 userquin

Hm, that didn't seem to do anything. It doesn't seem to work without vuetify-nuxt-module either, so must be something wrong with @nuxtjs/i18n? https://stackblitz.com/edit/github-coadyf?file=i18n.config.ts,nuxt.config.ts,app.vue,lang%2Fes-ES.json,package.json

Spomething to do with this maybe? https://github.com/nuxt-modules/i18n/issues/2192

AasmundN avatar Aug 07 '23 16:08 AasmundN

i18n module version? I'll try to figure out what's happening...

userquin avatar Aug 07 '23 16:08 userquin

Using rc 2. Have also tried beta 13, with no luck. Thanks 🙏

AasmundN avatar Aug 07 '23 17:08 AasmundN

@AasmundN It is weird, your repro working, check my fork here: https://stackblitz.com/edit/github-6zjd6y-eqyxxp?file=.npmrc

I've only change the package manager adding .npmrc

userquin avatar Aug 07 '23 17:08 userquin

Hmm, yes your fork works. Weird. Maybe it's some sort of problem with npm? However, when I add another locale and corresponding file and then set that as the default locale it stops working again: https://stackblitz.com/edit/github-6zjd6y-axgyjt?file=i18n.config.ts,app.vue

I get an error in the console: [Vue warn]: Hydration text mismatch

And if I don't set the second locale as the default one, the second locale is not loaded properly: https://stackblitz.com/edit/github-6zjd6y-xfkw7g?file=i18n.config.ts,nuxt.config.ts

If lazy is set to false it seems to work.

AasmundN avatar Aug 07 '23 20:08 AasmundN

https://github.com/nuxt-modules/i18n/issues/2300

AasmundN avatar Aug 18 '23 15:08 AasmundN