intlify / vue-i18n

Vue I18n for Vue 3
https://vue-i18n.intlify.dev/
MIT License
2.15k stars 327 forks source link

Is there any way to make injected properties local scope in Composition mode #994

Open LasyIsLazy opened 2 years ago

LasyIsLazy commented 2 years ago

Clear and concise description of the problem

For some reason, I have to use both Vue composition API and Vue legacy API in my project.

I prefer composition API, so I set legacy: false and globalInjection: true, i18n will be in Composition mode and I can use $i18n in code.

But $i18n.locale always refers to global scope locale, and I can't use local scope in Vue legacy code.

Suggested solution

Add some config to change injected properties's scope, when the Vue component have locale scope, injected properties can refers to local scope

Alternative

No response

Additional context

No response

Validations

LasyIsLazy commented 2 years ago

Or maybe export some API that can access local i18n composer from Legacy Vue code

LasyIsLazy commented 2 years ago

Additionally, $i18n refers to local scope when there is i18n option in Legacy mode.