`addRouterMiddleware` is not working with `@intlify/nuxt3`
aloulouamine opened this issue · comments
Hello,
When using a global addRouterMiddleware
from a nuxt plugin with @intlify/nuxt3
the first load misses the global router middleware.
Here a reproduction example :
https://stackblitz.com/edit/github-9wkf8t-t2us5t?file=plugins/middleware.ts
You can access the global instance:
const { vueApp } = useNuxtApp();
const { t } = vueApp.__VUE_I18N__.global;
You can access the global instance:
const { vueApp } = useNuxtApp(); const { t } = vueApp.__VUE_I18N__.global;
@vis97c Any idea how to change the global locale from here ?
I tried to change the i18n.locale but it doesn't reflect on the translations ...
(Trying to do localized routes ..)
@copostic this Is what I'm doing on my own project, basically you change locale which is a ref. I didn't have my PC at hand so I took a screenshot on my phone, sorry. Hope it helps
Cleaner solution :
const { vueApp } = useNuxtApp()
vueApp.config.globalProperties.$i18n.locale = yourLocale