30 lines
549 B
TypeScript
30 lines
549 B
TypeScript
|
|
import i18n from "i18next";
|
||
|
|
import { initReactI18next } from "react-i18next";
|
||
|
|
|
||
|
|
import en from "./locales/en.json";
|
||
|
|
import zh from "./locales/zh.json";
|
||
|
|
|
||
|
|
const resources = {
|
||
|
|
en: {
|
||
|
|
translation: en,
|
||
|
|
},
|
||
|
|
zh: {
|
||
|
|
translation: zh,
|
||
|
|
},
|
||
|
|
};
|
||
|
|
|
||
|
|
i18n.use(initReactI18next).init({
|
||
|
|
resources,
|
||
|
|
lng: "en", // 默认语言设置为英文
|
||
|
|
fallbackLng: "en", // 回退语言也设置为英文
|
||
|
|
|
||
|
|
interpolation: {
|
||
|
|
escapeValue: false, // React 已经默认转义
|
||
|
|
},
|
||
|
|
|
||
|
|
// 开发模式下显示调试信息
|
||
|
|
debug: false,
|
||
|
|
});
|
||
|
|
|
||
|
|
export default i18n;
|