refactor: enum i18n

This commit is contained in:
naiba
2024-12-14 10:39:07 +08:00
parent d67b9ff4d2
commit b9a8651371
12 changed files with 258 additions and 95 deletions

View File

@@ -1,6 +1,6 @@
import { TFunction } from "i18next"
import i18n from "@/lib/i18n"
export const triggerModes = (t: TFunction<"translation", undefined>) => ({
0: t("Always"),
1: t("Once"),
})
export const triggerModes: Record<number, string> = {
0: i18n.t("Always"),
1: i18n.t("Once"),
}

View File

@@ -1,12 +1,12 @@
import { TFunction } from "i18next"
import i18n from "@/lib/i18n"
export const cronTypes = (t: TFunction<"translation", undefined>) => ({
0: t("Scheduled"),
1: t("Trigger"),
})
export const cronTypes: Record<number, string> = {
0: i18n.t("Scheduled"),
1: i18n.t("Trigger"),
}
export const cronCoverageTypes = (t: TFunction<"translation", undefined>) => ({
0: t("Coverages.Only"),
1: t("Coverages.Excludes"),
2: t("Coverages.Alarmed"),
})
export const cronCoverageTypes: Record<number, string> = {
0: i18n.t("Coverages.Only"),
1: i18n.t("Coverages.Excludes"),
2: i18n.t("Coverages.Alarmed"),
}

View File

@@ -1,4 +1,4 @@
import { TFunction } from "i18next"
import i18n from "@/lib/i18n"
export const serviceTypes: Record<number, string> = {
1: "HTTP GET",
@@ -6,7 +6,7 @@ export const serviceTypes: Record<number, string> = {
3: "TCPing",
}
export const serviceCoverageTypes = (t: TFunction<"translation", undefined>) => ({
0: t("Coverages.Excludes"),
1: t("Coverages.Only"),
})
export const serviceCoverageTypes: Record<number, string> = {
0: i18n.t("Coverages.Excludes"),
1: i18n.t("Coverages.Only"),
}

View File

@@ -1,9 +1,9 @@
import { TFunction } from "i18next"
import i18n from "@/lib/i18n"
export const settingCoverageTypes = (t: TFunction<"translation", undefined>) => ({
1: t("Coverages.Excludes"),
2: t("Coverages.Only"),
})
export const settingCoverageTypes: Record<number, string> = {
1: i18n.t("Coverages.Excludes"),
2: i18n.t("Coverages.Only"),
}
export const nezhaLang: Record<string, string> = {
"zh-CN": "简体中文(中国大陆)",
@@ -11,8 +11,8 @@ export const nezhaLang: Record<string, string> = {
"en-US": "English",
}
export const wafBlockReasons = (t: TFunction<"translation", undefined>) => ({
1: t("LoginFailed"),
2: t("BruteForceAttackingToken"),
3: t("BruteForceAttackingAgentSecret"),
})
export const wafBlockReasons: Record<number, string> = {
1: i18n.t("LoginFailed"),
2: i18n.t("BruteForceAttackingToken"),
3: i18n.t("BruteForceAttackingAgentSecret"),
}