nuxt3 icon indicating copy to clipboard operation
nuxt3 copied to clipboard

`addRouterMiddleware` is not working with `@intlify/nuxt3`

Open aloulouamine opened this issue 3 years ago • 4 comments

Hello,

When using a global addRouterMiddleware from a nuxt plugin with @intlify/nuxt3the first load misses the global router middleware.

Here a reproduction example : https://stackblitz.com/edit/github-9wkf8t-t2us5t?file=plugins/middleware.ts

https://github.com/nuxt/nuxt.js/issues/13794

aloulouamine avatar Apr 21 '22 11:04 aloulouamine

You can access the global instance:

const { vueApp } = useNuxtApp();
const { t } = vueApp.__VUE_I18N__.global;

vis97c avatar Apr 28 '22 18:04 vis97c

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 avatar Jun 17 '22 13:06 copostic

@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

Screenshot_20220617-153759_Chrome

vis97c avatar Jun 17 '22 20:06 vis97c

Cleaner solution :

const { vueApp } = useNuxtApp()
vueApp.config.globalProperties.$i18n.locale = yourLocale

Skyost avatar Jul 25 '22 15:07 Skyost