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