Getting Started
NPM package installation
$ npm install vue-i18n-manager
Plugin installation
Vue 2.0 and Vuex are required
The basic installation only requires a vuex
store instance in order to run, because has English as a default language.
Vue.use(VueI18nManager, { store })
If you decide to to add your custom default language, then you need: a language and its translation and a default language code.
Vue.use(VueI18nManager, {
store,
config: {
defaultCode: 'en-GB',
languages: [
{
name: 'English',
code: 'en-GB',
urlPrefix: 'en',
translationKey: 'en'
}
],
translations: {
en: {
message: 'hello!'
}
},
}
})
The configuration is done! Now you only need to initialize the plugin just like this
Vue.initI18nManager()
It is also possible to mount the application after the language manager has done everything, to avoid the labels of the translation to flicker meanwhile your data is loading
(necessary if you are loading data asynchronously)
const app = new Vue({...})
Vue.initI18nManager.then(() => {
app.$mount('#app')
})
to more complex configurations, please check the configurations section.