{{ $t('key') }} dies
See original GitHub issueI am not able to use $t in any view. Looks like a Bug.
TypeError: Cannot read property '_t' of undefined
at Proxy.Vue.$t (vue-i18n.esm.js:178)
at Proxy.render (app.vue?./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options:24)
at VueComponent.Vue._render (vue.esm.js:3545)
at VueComponent.updateComponent (vue.esm.js:4063)
at Watcher.get (vue.esm.js:4476)
at new Watcher (vue.esm.js:4465)
at mountComponent (vue.esm.js:4070)
at VueComponent.Vue.$mount (vue.esm.js:9047)
at VueComponent.Vue.$mount (vue.esm.js:11941)
at init (vue.esm.js:3124)
// app.js
import Vue from 'vue';
// use
import VueI18n from './vue-config-i18n.js';
Vue.use(VueI18n);
...
new Vue({
el: '#app',
template: '<app/>',
// Register App Component
components: {
app: App
}
});
// vue-config-i18n.js
import VueI18n from 'vue-i18n';
import lang_de from '@/lang/de.json'; // gets imported.
export default {
install (Vue, options) {
Vue.use(VueI18n);
let i18n = new VueI18n({
locale: 'de',
fallbackLocale: 'de',
});
(async ()=>{
let lang = 'de';
//let msgs = await import('@/lang/'+lang+'.json');
let msgs = lang_de;
if (msgs) {
i18n.setLocaleMessage(lang, msgs.default || msgs);
i18n.lang = lang;
console.log('i18n loaded lang', lang);
}
else {
console.warn('i18n did not load lang', lang);
}
})();
}
}
// app.vue
<template>
<div>
{{ $t('hello') }}
</div>
</template>
// ./lang/de.json
{
"hello": "Hallo Welt"
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Key Dies, Inc: Steel Rule Dies
Key Dies has the technical craftsmanship and technology to manufacture high quality and accurate steel rule dies and related tooling for your die...
Read more >What To Do When Your Toyota Smart Key Dies
If your Toyota Smart Key dies, don't panic. Our Toyota dealer near Pasadena will tell you just how to unlock and start your...
Read more >These Tricks Will Save You When Your Key Fob Dies
Don't panic if your key fob dies and you don't have a replacement battery. These little-known methods will get you back on the...
Read more >What to Do When Your Key Fob Dies - MotorBiscuit.com
Key fobs can last a long time on a small battery, but they will eventually die, leaving us all in a pickle. As...
Read more >Key Fob Dead? Push Button Start Car Won't?? Can't Get In ...
A dead battery in the remote control, smart key, intelligent key, key fob, you're in the right place! Never a charge to use,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FWIW the module approach doesn’t seem to work. The setup that worked for me (with Vue CLI) is instantiating
VueI18n
insidemain.js
.@kazupon so you say, the module is not compatible to the Vue’s default method of
Vue.use(..plugin..)
? As I did show above (app.js) what I tried. What ever$mount
is for, is does not match the vue guide. I would not have asked, and would not be the only one having trouble, if the vue-i18n docs would be crystal clear on this.Could you please at least consider explaining the difference to why it is not like in the guide? I might then be able to adapt your code.