diff --git a/src/templates/plugin.routing.js b/src/templates/plugin.routing.js index a300ef5fd..23fd8f60f 100644 --- a/src/templates/plugin.routing.js +++ b/src/templates/plugin.routing.js @@ -209,9 +209,17 @@ const plugin = { export default (context) => { Vue.use(plugin) - const { app, store = {} } = context - app.localePath = store.localePath = NuxtContextProxy(context, localePath) - app.localeRoute = store.localeRoute = NuxtContextProxy(context, localeRoute) - app.switchLocalePath = store.switchLocalePath = NuxtContextProxy(context, switchLocalePath) - app.getRouteBaseName = store.getRouteBaseName = NuxtContextProxy(context, getRouteBaseName) + const { app, store } = context + + app.localePath = NuxtContextProxy(context, localePath) + app.localeRoute = NuxtContextProxy(context, localeRoute) + app.switchLocalePath = NuxtContextProxy(context, switchLocalePath) + app.getRouteBaseName = NuxtContextProxy(context, getRouteBaseName) + + if (store) { + store.localePath = app.localePath + store.localeRoute = app.localeRoute + store.switchLocalePath = app.switchLocalePath + store.getRouteBaseName = app.getRouteBaseName + } }