Files
stream.ui/src/i18n/index.ts
claude 3491a0a08e 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>
2026-03-06 03:02:06 +00:00

20 lines
769 B
TypeScript

import type { i18n as I18nInstance } from 'i18next';
import { getClientI18nInstance } from '@/lib/translation/client';
import { defaultLocale, supportedLocales, type SupportedLocale } from './constants';
export { supportedLocales, defaultLocale } from './constants';
export type { SupportedLocale } from './constants';
export { localeCookieKey } from './constants';
export const normalizeLocale = (locale?: string): SupportedLocale => {
if (!locale) return defaultLocale;
const normalized = locale.toLowerCase().split('-')[0] as SupportedLocale;
return supportedLocales.includes(normalized) ? normalized : defaultLocale;
};
export const getActiveI18n = (): I18nInstance | undefined => {
return import.meta.env.SSR ? undefined : getClientI18nInstance();
};