-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vite build ends up with "[intlify] Not found '...' key in '...' locale messages." #147
Comments
Fixed it (partially): const messages = {
en: {
hello: 'hello world'
},
ja: {
hello: 'こんにちは、世界'
},
de: {
hello: 'hi!'
},
}
/*
doesn't work
const messages = {
en: {
message: {
hello: 'hello world'
}
},
ja: {
message: {
hello: 'こんにちは、世界'
}
},
de: {
message: {
hello: 'hi!'
}
}
}
*/
const i18n = createI18n({
globalInjection: true,
locale: 'ja',
fallbackLocale: 'en',
legacy: false,
messages
}) However, the i18n section in an SFC is still ignored: App.vue <template>
<div class="flex justify-center text-3xl py-16">{{ $t('hello') }}</div>
</template>
<script>
export default {}
</script>
<i18n>
{
"de": {
"hello": "foo"
},
"en": {
"hello": "bar"
},
"ja": {
"hello": "baz"
}
}
</i18n> Results in
|
I haven't tried mixing global and custom blocks, but using only custom blocks is ok for me. |
I changed 2 things to get rid of this error: app.js let userLocale = 'en' if (navigator.language === 'pl') { userLocale = 'pl' } const i18n = createI18n({ legacy: 'composition', inheritLocale: true,// must be removed globalInjection: true, locale: userLocale,// manually set locale messages: { en: en, pl: pl, } })
vite.config.js vueI18n({ // This line must be removed. include: resolve(dirname(fileURLToPath(import.meta.url)), 'resources/js/locale/**'), }), |
What if I don't have messages beforehand and get them from API? |
Setting up vite with vite-plugin-vue-i18n according to the documentation followed by
npm run dev
and navigating tolocalhost:<port>
Will always display "message" and the console tells meBoth in a "full-scale" application and the minimal example below.
Expected behavior
Localized message string.
Reproduction
package.json
vite.config.js
index.js
App.vue
Issue Package
vite-plugin-vue-i18n
System Info
Screenshot
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: