mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-02-04 20:50:07 +00:00
fix: Kill auto language (#21)
* fix: Kill auto language Kill the background automatic recognition of language to prevent backend Language file correction * refactor(Aggregate): Ports and install hosts Optimize multi-language * fix(I18n): Kill spurious shortcuts Fix wrong import
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import i18n from "i18next";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
import LanguageDetector from "i18next-browser-languagedetector";
|
||||
|
||||
import enTranslation from "../locales/en/translation.json";
|
||||
import itTranslation from "../locales/it/translation.json";
|
||||
@@ -22,16 +21,22 @@ const resources = {
|
||||
},
|
||||
};
|
||||
|
||||
const getStoredLanguage = () => {
|
||||
return localStorage.getItem("language") || "zh-CN";
|
||||
};
|
||||
|
||||
i18n.use(initReactI18next)
|
||||
.use(LanguageDetector)
|
||||
.init({
|
||||
resources,
|
||||
lng: getStoredLanguage(), // 使用localStorage中存储的语言或默认值
|
||||
fallbackLng: "en", // 当前语言的翻译没有找到时,使用的备选语言
|
||||
interpolation: {
|
||||
escapeValue: false, // react已经安全地转义
|
||||
},
|
||||
});
|
||||
|
||||
i18n.on("languageChanged", (lng) => {
|
||||
localStorage.setItem("language", lng);
|
||||
});
|
||||
|
||||
export default i18n;
|
||||
Reference in New Issue
Block a user