Closed Konafets closed 6 years ago
Nice find, we should update the README with info about this!
So, I got around this error, like this.
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import Locales from './vue-i18n-locales.generated.js'
Vue.use(VueI18n)
const i18n = new VueI18n({locale: 'en', messages: Locales})
const app = new Vue({
i18n,
el: '#app',
})
I've tried changing the language to other than English, selecting the Vue root instance in devtools and running
$vm0.$i18n.locale = 'es'
and it works fine.
@Abonive Something similar is already documented in the README (a default language needs to be set):
import Vue from 'vue';
import VueInternalization from 'vue-i18n';
import Locales from './vue-i18n-locales.generated.js';
Vue.use(VueInternalization);
Vue.config.lang = 'en';
...
Also gonna close this, as documented solutions is implemented in #31 and #34
I encountered that error above and read all issue reports at kazupon/vue-i18n repo. The error happens apparently because the Vue instance is loaded before the localization.
One guy pointed to vuex-i18n, another translation lib. I gave it a shot and this worked like a charm. The best thing: I could use the generated localization files from this package with vuex-i18n. Here is my setup:
The
Laravel.locale
comes from my Layout: