vike-vue: Can't get vue-i18n to work with +onCreateApp #1778
-
I'm trying to use I've attached a minimal reproduction case here: vike-repro.zip This is the onCreateApp hook, just like in the example templates: // https://vike.dev/onCreateApp
import type { OnCreateAppSync } from 'vike-vue';
import { i18n } from '../i18n';
export const onCreateApp: OnCreateAppSync = (pageContext) => {
const { app } = pageContext;
app.use(i18n);
return app;
} and the view component: <template>
<h1>Test page</h1>
<p>this is a loalized string: {{$t('common.test')}}</p>
</template> I can see the log for each page being built, so it's not an issue due to file naming or similar problems.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Publish the reproduction on GitHub. |
Beta Was this translation helpful? Give feedback.
-
It seems this is down to vue-i18n misbehaving wrt global variables in a way that causes an Exception in node but not in browsers. import type { OnCreateAppSync } from 'vike-vue';
import { i18n } from '../i18n';
export const onCreateApp: OnCreateAppSync = (pageContext) => {
const { app } = pageContext;
// workaround for vue-i18n SSR bug
if (!('__VUE_PROD_DEVTOOLS__' in globalThis)) {
(globalThis as any).__VUE_PROD_DEVTOOLS__ = false;
}
app.use(i18n);
} |
Beta Was this translation helpful? Give feedback.
It seems this is down to vue-i18n misbehaving wrt global variables in a way that causes an Exception in node but not in browsers.
The following workaround get s things moving: