add i18n middlware

This commit is contained in:
lesion 2019-07-23 01:33:13 +02:00
parent f9e0883eaf
commit 2402511cf3

7
middleware/i18n.js Normal file
View file

@ -0,0 +1,7 @@
export default function ({ req, app, store }) {
if (process.server) {
const lang = req.acceptsLanguages('en', 'it')
store.commit('setLocale', lang || 'it')
app.i18n.locale = store.state.locale
}
}