Nuxt/examples/i18n/plugins/i18n.js
Sebastien Chopin 9d43db475b Fix example
2017-09-01 17:38:16 +02:00

18 lines
461 B
JavaScript

import Vue from 'vue'
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
export default ({ app, isClient, store, serverStore }) => {
// Set i18n instance on app
// This way we can use it in middleware and pages asyncData/fetch
app.i18n = new VueI18n({
locale: (isClient ? serverStore.locale : store.state.locale),
fallbackLocale: 'en',
messages: {
'en': require('~/locales/en.json'),
'fr': require('~/locales/fr.json')
}
})
}