fix i18n runtime scoping for SSR requests

Create a dedicated i18next instance per SSR request and remove server context-storage coupling from translation runtime, while keeping a separate client singleton path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 03:02:06 +00:00
parent 6d04f1cbdc
commit 3491a0a08e
5 changed files with 45 additions and 40 deletions

View File

@@ -1,6 +1,6 @@
import type { i18n as I18nInstance } from 'i18next';
import { getActiveI18nInstance } from '@/lib/translation';
import { getClientI18nInstance } from '@/lib/translation/client';
import { defaultLocale, supportedLocales, type SupportedLocale } from './constants';
@@ -15,5 +15,5 @@ export const normalizeLocale = (locale?: string): SupportedLocale => {
};
export const getActiveI18n = (): I18nInstance | undefined => {
return getActiveI18nInstance();
return import.meta.env.SSR ? undefined : getClientI18nInstance();
};