Files
makelore/src/i18n/index.ts
inman 26b52d76e3
Some checks failed
Electron E2E / Electron E2E (macos-latest) (push) Has been cancelled
Electron E2E / Electron E2E (ubuntu-latest) (push) Has been cancelled
Electron E2E / Electron E2E (windows-latest) (push) Has been cancelled
feat: 完善图像工作区与创作工具体验
2026-08-16 14:08:27 +08:00

48 lines
1.3 KiB
TypeScript

import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import {
SUPPORTED_LANGUAGE_CODES,
resolveSupportedLanguage,
type LanguageCode,
} from '../../shared/language';
// ZH
import zhCommon from './locales/zh/common.json';
import zhSettings from './locales/zh/settings.json';
import zhChat from './locales/zh/chat.json';
import zhSetup from './locales/zh/setup.json';
import zhDashboard from './locales/zh/dashboard.json';
export const SUPPORTED_LANGUAGES = [
{ code: 'zh', label: '中文' },
] as const satisfies ReadonlyArray<{ code: LanguageCode; label: string }>;
const resources = {
zh: {
common: zhCommon,
settings: zhSettings,
chat: zhChat,
setup: zhSetup,
dashboard: zhDashboard,
},
};
i18n
.use(initReactI18next)
.init({
resources,
lng: resolveSupportedLanguage(typeof navigator !== 'undefined' ? navigator.language : undefined),
fallbackLng: 'zh',
supportedLngs: [...SUPPORTED_LANGUAGE_CODES],
defaultNS: 'common',
ns: ['common', 'settings', 'chat', 'setup', 'dashboard'],
interpolation: {
escapeValue: false, // React already escapes
},
react: {
useSuspense: false,
},
});
export default i18n;