2017-02-08 17:49:16 +00:00
|
|
|
import Vue from 'vue'
|
2017-04-14 09:55:04 +00:00
|
|
|
import VueI18n from 'vue-i18n'
|
2017-02-08 17:49:16 +00:00
|
|
|
|
2017-04-14 09:55:04 +00:00
|
|
|
Vue.use(VueI18n)
|
|
|
|
|
2017-10-28 15:20:11 +00:00
|
|
|
export default ({ app, store }) => {
|
2017-05-21 19:01:08 +00:00
|
|
|
// Set i18n instance on app
|
|
|
|
// This way we can use it in middleware and pages asyncData/fetch
|
|
|
|
app.i18n = new VueI18n({
|
2017-09-06 13:32:09 +00:00
|
|
|
locale: store.state.locale,
|
2017-05-21 19:01:08 +00:00
|
|
|
fallbackLocale: 'en',
|
|
|
|
messages: {
|
2019-11-26 22:42:39 +00:00
|
|
|
en: require('~/locales/en.json'),
|
|
|
|
fr: require('~/locales/fr.json')
|
2017-05-21 19:01:08 +00:00
|
|
|
}
|
|
|
|
})
|
2017-12-01 12:48:30 +00:00
|
|
|
|
2017-12-01 12:38:45 +00:00
|
|
|
app.i18n.path = (link) => {
|
2017-12-01 12:33:33 +00:00
|
|
|
if (app.i18n.locale === app.i18n.fallbackLocale) {
|
|
|
|
return `/${link}`
|
|
|
|
}
|
|
|
|
|
|
|
|
return `/${app.i18n.locale}/${link}`
|
|
|
|
}
|
2017-05-21 19:01:08 +00:00
|
|
|
}
|