feat: Add i18n

This commit is contained in:
elvis liao
2024-09-26 17:53:44 +08:00
parent a9fdceca6f
commit 85df8eb09d
6 changed files with 341 additions and 1 deletions

33
ui/src/i18n/index.ts Normal file
View File

@@ -0,0 +1,33 @@
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'
i18n
.use(LanguageDetector)
.use(initReactI18next)
.init({
resources: {
zh: {
name: '简体中文',
translation: zh
},
en: {
name: 'English',
translation: en
}
},
fallbackLng: 'zh',
debug: true,
interpolation: {
escapeValue: false,
},
backend: {
loadPath: '/locales/{{lng}}.json',
}
});
export default i18n;