You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given that vuei18n runs in legacy mode and composition is also enabled during ssr the translations are always empty when useI18n is being invoked inside component setup.
This is because the "useI18nForLegacy" implementation only populates the composer instance during the "onBeforeMount" lifecycle hook, whereas the non legacy implementation also populates it on the server side.
Workaround:
When invoking useI18n pass in the "__useComponent: true" option, which will force useI18n to execute the non legacy implementation.
useI18n({__useComponent: true})
Why is this an issue?
The __useComponent flag appears to be an internal property and is not documented anywhere
The __useComponent flag is not part of the type definition
This behavior of useI18n in legacy mode is also not documented
Expected behavior
useI18n inside component setup should automatically not use the legacy implementation or the legacy implementation should populate the composer instance during ssr
We have the same issue without SSR: Without passing this option, translations are empty when I try to access them within <script setup>. We cannot disable legacy mode at the moment as we still have a lot of legacy components.
Reporting a bug?
Given that vuei18n runs in legacy mode and composition is also enabled during ssr the translations are always empty when useI18n is being invoked inside component setup.
This is because the "useI18nForLegacy" implementation only populates the composer instance during the "onBeforeMount" lifecycle hook, whereas the non legacy implementation also populates it on the server side.
Workaround:
useI18n
pass in the "__useComponent: true" option, which will forceuseI18n
to execute the non legacy implementation.Why is this an issue?
useI18n
in legacy mode is also not documentedExpected behavior
useI18n
inside component setup should automatically not use the legacy implementation or the legacy implementation should populate the composer instance during ssrReproduction
npm install && npm run dev
System Info
Screenshot
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: