Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addRouterMiddleware is not working with @intlify/nuxt3 #51

Open
aloulouamine opened this issue Apr 21, 2022 · 4 comments
Open

addRouterMiddleware is not working with @intlify/nuxt3 #51

aloulouamine opened this issue Apr 21, 2022 · 4 comments

Comments

@aloulouamine
Copy link

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

nuxt/nuxt#13794

@vis97c
Copy link

vis97c commented Apr 28, 2022

You can access the global instance:

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

@copostic
Copy link

copostic commented Jun 17, 2022

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 ..)

@vis97c
Copy link

vis97c commented Jun 17, 2022

@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

@Skyost
Copy link

Skyost commented Jul 25, 2022

Cleaner solution :

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants