replace vue-i18n with i18next-vue
Complete the i18n migration by switching runtime setup and remaining components to i18next-vue, and add shared locale constants/helpers for SSR and client language handling. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
19
src/i18n/index.ts
Normal file
19
src/i18n/index.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { i18n as I18nInstance } from 'i18next';
|
||||
|
||||
import { getActiveI18nInstance } from '@/lib/translation';
|
||||
|
||||
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 getActiveI18nInstance();
|
||||
};
|
||||
Reference in New Issue
Block a user