refactor(i18n): isolate Vue I18n instances per request for SSR

Replace global I18n singleton with a factory function
Inject request-specific I18n instances into Nuxt app and SEO metadata
Prevent cross-request locale state pollution during server-side rendering
This commit is contained in:
2026-05-06 10:10:07 +08:00
parent 337a6bda1f
commit cf1eb6965e
6 changed files with 86 additions and 27 deletions

View File

@@ -1,5 +1,15 @@
import { i18n } from '../src/i18n';
import { createPokopiaI18n, setActiveI18n } from '../src/i18n';
export default defineNuxtPlugin((nuxtApp) => {
const i18n = createPokopiaI18n();
if (import.meta.client) {
setActiveI18n(i18n);
}
nuxtApp.vueApp.use(i18n);
return {
provide: {
pokopiaI18n: i18n
}
};
});