Nuxt/examples/i18n/middleware/i18n.js
Sébastien Chopin 2c7eecace7 Fix i18n example
2017-02-10 12:55:51 +01:00

9 lines
307 B
JavaScript

export default async function ({ store, params, error }) {
const lang = params.lang || 'en'
if (!store.state.lang.locales.includes(lang)) {
await store.dispatch('lang/setLang', 'en')
return error({ message: 'Page not found', statusCode: 404 })
}
await store.dispatch('lang/setLang', lang)
}