mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-02-04 04:30:06 +00:00
fix(I18n): Translation supplement
Translation supplement, automatic lanSupplement the missing translations
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
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";
|
||||
@@ -21,22 +22,16 @@ const resources = {
|
||||
},
|
||||
};
|
||||
|
||||
const getStoredLanguage = () => {
|
||||
return localStorage.getItem("language") || "zh-CN";
|
||||
};
|
||||
|
||||
i18n.use(initReactI18next).init({
|
||||
resources,
|
||||
lng: getStoredLanguage(), // 使用localStorage中存储的语言或默认值
|
||||
fallbackLng: "en", // 当前语言的翻译没有找到时,使用的备选语言
|
||||
interpolation: {
|
||||
escapeValue: false, // react已经安全地转义
|
||||
},
|
||||
});
|
||||
i18n.use(initReactI18next)
|
||||
.use(LanguageDetector)
|
||||
.init({
|
||||
resources,
|
||||
fallbackLng: "en", // 当前语言的翻译没有找到时,使用的备选语言
|
||||
interpolation: {
|
||||
escapeValue: false, // react已经安全地转义
|
||||
},
|
||||
});
|
||||
|
||||
// 添加语言改变时的处理函数
|
||||
i18n.on("languageChanged", (lng) => {
|
||||
localStorage.setItem("language", lng);
|
||||
});
|
||||
|
||||
export default i18n;
|
||||
@@ -125,7 +125,7 @@
|
||||
"WAF": "Web application firewall",
|
||||
"SiteName": "Site name",
|
||||
"DashboardOriginalHost": "Dashboard Server Domain/IP without CDN",
|
||||
"Auto": "automatic recognition",
|
||||
"Auto": "Automatic",
|
||||
"LoginFailed": "Login failed",
|
||||
"BruteForceAttackingToken": "Brute Force Attacking Token",
|
||||
"BruteForceAttackingAgentSecret": "Brute Force Attacking Agent Secret",
|
||||
@@ -150,4 +150,4 @@
|
||||
"Count": "Count",
|
||||
"LastBlockReason": "Last Block Reason",
|
||||
"LastBlockTime": "Last ban time"
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,6 @@
|
||||
"TasksToTriggerAfterRecovery": "Attività da attivare dopo il ripristino",
|
||||
"Confirm": "Confermo",
|
||||
"ConfirmDeletion": "Confermi l'eliminazione?",
|
||||
"NewService": "Nuovo servizio",
|
||||
"Services": "Servizi",
|
||||
"ShowInService": "Mostra in servizio",
|
||||
"Coverages": {
|
||||
@@ -126,6 +125,7 @@
|
||||
"CreateService": "Crea servizio",
|
||||
"EditTask": "Modifica attività",
|
||||
"CreateTask": "Crea attività",
|
||||
"Auto": "automatico",
|
||||
"CreateNotifier": "Crea notifica",
|
||||
"EditNotifier": "Modifica notifica",
|
||||
"EditAlertRule": "Modifica le regole degli allarmi",
|
||||
@@ -150,4 +150,4 @@
|
||||
"Count": "contare",
|
||||
"LastBlockReason": "Motivo dell'ultimo divieto",
|
||||
"LastBlockTime": "L'ultima volta che è stato vietato"
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,6 @@
|
||||
"TasksToTriggerAfterRecovery": "恢复后要触发的任务",
|
||||
"Confirm": "确认",
|
||||
"ConfirmDeletion": "确认删除?",
|
||||
"NewService": "新服务",
|
||||
"Services": "服务",
|
||||
"ShowInService": "服务中显示",
|
||||
"Coverages": {
|
||||
@@ -149,5 +148,6 @@
|
||||
"NewUser": "新用户",
|
||||
"Count": "计数",
|
||||
"LastBlockReason": "最后封禁原因",
|
||||
"LastBlockTime": "最后封禁时间"
|
||||
}
|
||||
"LastBlockTime": "最后封禁时间",
|
||||
"Auto": "自动"
|
||||
}
|
||||
@@ -68,7 +68,6 @@
|
||||
"TasksToTriggerAfterRecovery": "恢復後要觸發的任務",
|
||||
"Confirm": "確認",
|
||||
"ConfirmDeletion": "確認刪除?",
|
||||
"NewService": "新服務",
|
||||
"Services": "服務",
|
||||
"ShowInService": "服務中顯示",
|
||||
"Coverages": {
|
||||
@@ -149,5 +148,6 @@
|
||||
"NewUser": "新用戶",
|
||||
"Count": "計數",
|
||||
"LastBlockReason": "最後封鎖原因",
|
||||
"LastBlockTime": "最後封鎖時間"
|
||||
}
|
||||
"LastBlockTime": "最後封鎖時間",
|
||||
"Auto": "自動"
|
||||
}
|
||||
@@ -48,7 +48,7 @@ const settingFormSchema = z.object({
|
||||
});
|
||||
|
||||
export default function SettingsPage() {
|
||||
const { t } = useTranslation();
|
||||
const { t , i18n} = useTranslation();
|
||||
const [config, setConfig] = useState<ModelConfig>();
|
||||
const [error, setError] = useState<Error>();
|
||||
|
||||
@@ -106,6 +106,11 @@ export default function SettingsPage() {
|
||||
return;
|
||||
} finally {
|
||||
toast(t("Success"));
|
||||
if (values.language!= "auto"){
|
||||
i18n.changeLanguage(values.language)
|
||||
}else{
|
||||
i18n.changeLanguage(i18n.services.languageDetector.detect());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
import i18next from "i18next";
|
||||
export const settingCoverageTypes: Record<number, string> = {
|
||||
1: "All excludes specific servers",
|
||||
2: "Only specific servers",
|
||||
1: i18next.t("Coverages.Excludes"),
|
||||
2: i18next.t("Coverages.Only"),
|
||||
}
|
||||
|
||||
export const nezhaLang: Record<string, string> = {
|
||||
"auto": i18next.t("Auto"),
|
||||
"zh_CN": "简体中文(中国大陆)",
|
||||
"zh_TW": "正體中文(台灣)",
|
||||
"en_US": "English",
|
||||
}
|
||||
|
||||
export const wafBlockReasons: Record<number, string> = {
|
||||
1: "Login failed",
|
||||
2: "Brute-force attacking token",
|
||||
3: "Brute-force attacking Agent secret",
|
||||
1: i18next.t("LoginFailed"),
|
||||
2: i18next.t("BruteForceAttackingToken"),
|
||||
3: i18next.t("BruteForceAttackingAgentSecret"),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user