Download code/frontend/apps/web/src/i18n.ts from Jiali9/Affect-Atlas: direct link, hf CLI and curl.
- Browser
- Download file 867 Bytes
-
https://huggingface.co/Jiali9/Affect-Atlas/resolve/main/code/frontend/apps/web/src/i18n.ts
- Command line
-
hf download hf://Jiali9/Affect-Atlas/code/frontend/apps/web/src/i18n.ts
-
curl -L -o i18n.ts https://huggingface.co/Jiali9/Affect-Atlas/resolve/main/code/frontend/apps/web/src/i18n.ts
867 Bytes
| import i18n from 'i18next' | |
| import { initReactI18next } from 'react-i18next' | |
| import LanguageDetector from 'i18next-browser-languagedetector' | |
| import zh from './locales/zh.json' | |
| import en from './locales/en.json' | |
| const resources = { | |
| zh: { translation: zh }, | |
| en: { translation: en }, | |
| } | |
| i18n | |
| .use(LanguageDetector) // 检测浏览器语言 | |
| .use(initReactI18next) // 传递 i18n 实例给 react-i18next | |
| .init({ | |
| resources, | |
| fallbackLng: 'en', // 默认语言 | |
| supportedLngs: ['zh', 'en'], // 支持的语言 | |
| detection: { | |
| // 语言检测顺序: localStorage > 浏览器语言 > 默认语言 | |
| order: ['localStorage', 'navigator'], | |
| caches: ['localStorage'], // 缓存用户选择 | |
| lookupLocalStorage: 'i18nextLng', | |
| }, | |
| interpolation: { | |
| escapeValue: false, // React 已经防止 XSS | |
| }, | |
| }) | |
| export default i18n | |