gancio-upstream/plugins/i18n.js

23 lines
565 B
JavaScript
Raw Normal View History

2019-04-03 00:25:12 +02:00
import Vue from 'vue'
import VueI18n from 'vue-i18n'
2019-07-23 01:31:43 +02:00
import it from '../locales/it.js'
import en from '../locales/en.js'
2019-07-24 21:26:56 +02:00
import merge from 'lodash/merge'
2019-04-03 00:25:12 +02:00
Vue.use(VueI18n)
2019-07-24 21:26:56 +02:00
export default async ({ app, store }) => {
2019-04-03 00:25:12 +02:00
// Set i18n instance on app
// This way we can use it in middleware and pages asyncData/fetch
2019-07-24 21:26:56 +02:00
const user_locale = await app.$axios.$get('/settings/user_locale')
2019-04-03 00:25:12 +02:00
app.i18n = new VueI18n({
2019-06-25 01:05:38 +02:00
locale: store.state.locale,
fallbackLocale: 'it',
2019-04-26 23:14:43 +02:00
messages: {
2019-07-24 21:26:56 +02:00
it: merge(it, user_locale),
en: merge(en, user_locale)
2019-04-26 23:14:43 +02:00
}
2019-04-03 00:25:12 +02:00
})
}