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