useI18n
does not work in web component when using Vue 3.5's configureApp
option
#2015
Open
4 tasks done
Labels
Status: Review Needed
Request for review comments
Reporting a bug?
Vue 3.5 added a new way of passing plugins to Vue web components: https://blog.vuejs.org/posts/vue-3-5#custom-elements-improvements
Unfortunately using
useI18n()
does not work inside the web component.However, it does work inside a normal vue component that is used by the vue web component.
Expected behavior
When vue-i18n is registered using
configureApp
,useI18n
should work with vue web components and normal vue components.Reproduction
Minimal reproduction on stackblitz: https://stackblitz.com/edit/vitejs-vite-egcpgj?file=src%2Fcomponents%2FVueCustomElement.ce.vue
System Info
Screenshot
No response
Additional context
I think this is caused by this part:
vue-i18n/packages/vue-i18n-core/src/i18n.ts
Lines 792 to 807 in cea7cb4
If an instance is a WebComponent/CustomElement it tries to inject it using
I18nInjectionKey
. But because i18n was registered usingconfigureApp
, it is available oninstance.appContext.app.__VUE_I18N_SYMBOL__!
, notI18nInjectionKey
.Validations
The text was updated successfully, but these errors were encountered: