From 65efc6babddb28d8d27ff7109e1a117b4867b2ac Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Thu, 9 Jun 2022 16:09:20 +0800 Subject: [PATCH] i18n: captcha settings --- public/locales/en-US/dashboard.json | 37 ++++- public/locales/zh-CN/dashboard.json | 37 ++++- src/component/Admin/Setting/Captcha.js | 210 +++++++++++++++---------- 3 files changed, 198 insertions(+), 86 deletions(-) diff --git a/public/locales/en-US/dashboard.json b/public/locales/en-US/dashboard.json index ecb7a01..a517f2e 100644 --- a/public/locales/en-US/dashboard.json +++ b/public/locales/en-US/dashboard.json @@ -208,6 +208,41 @@ "thumbFormatDes": "Available: png/jpg", "thumbQuality": "Quality", "thumbQualityDes": "Compression quality percentage, valid only for jpg encoding.", - "thumbGC": "Run GC after thumb generated" + "thumbGC": "Run GC after thumb generated", + "captcha": "Captcha", + "captchaType": "Captcha type", + "plainCaptcha": "Plain", + "reCaptchaV2": "reCAPTCHA V2", + "tencentCloudCaptcha": "Tencent Cloud Captcha", + "captchaProvider": "Provider of the captcha service.", + "plainCaptchaTitle": "Plain captcha", + "captchaWidth": "Width", + "captchaHeight": "Height", + "captchaLength": "Length", + "captchaMode": "Mode", + "captchaModeNumber": "Numbers", + "captchaModeLetter": "Letters", + "captchaModeMath": "Math", + "captchaModeNumberLetter": "Numbers + Letters", + "captchaElement": "Elements inside of the captcha image.", + "complexOfNoiseText": "Complex of noise text", + "complexOfNoiseDot": "Complex of noise dots", + "showHollowLine": "Show hollow lines", + "showNoiseDot": "Show noise dots", + "showNoiseText": "Show noise text", + "showSlimeLine": "Show slime lines", + "showSineLine": "Show sine lines", + "siteKey": "Site KEY", + "siteKeyDes": "You can find it at <0>App Management Page.", + "siteSecret": "Secret", + "siteSecretDes": "You can find it at <0>App Management Page.", + "secretID": "SecretId", + "secretIDDes": "You can find it at <0>Access Management Page.", + "secretKey": "SecretKey", + "secretKeyDes": "You can find it at <0>Access Management Page.", + "tCaptchaAppID": "APPID", + "tCaptchaAppIDDes": "You can find it at <0>Captcha Management Page.", + "tCaptchaSecretKey": "App Secret Key", + "tCaptchaSecretKeyDes": "You can find it at <0>Captcha Management Page." } } \ No newline at end of file diff --git a/public/locales/zh-CN/dashboard.json b/public/locales/zh-CN/dashboard.json index 1f746a1..d2ade7d 100644 --- a/public/locales/zh-CN/dashboard.json +++ b/public/locales/zh-CN/dashboard.json @@ -208,6 +208,41 @@ "thumbFormatDes": "可选:png/jpg", "thumbQuality": "图像质量", "thumbQualityDes": "压缩质量百分比,只针对 jpg 编码有效", - "thumbGC": "生成完成后立即回收内存" + "thumbGC": "生成完成后立即回收内存", + "captcha": "验证码", + "captchaType": "验证码类型", + "plainCaptcha": "普通", + "reCaptchaV2": "reCAPTCHA V2", + "tencentCloudCaptcha": "腾讯云验证码", + "captchaProvider": "验证码类型", + "plainCaptchaTitle": "普通验证码", + "captchaWidth": "宽度", + "captchaHeight": "高度", + "captchaLength": "长度", + "captchaMode": "模式", + "captchaModeNumber": "数字", + "captchaModeLetter": "字母", + "captchaModeMath": "算数", + "captchaModeNumberLetter": "数字+字母", + "captchaElement": "验证码的形式", + "complexOfNoiseText": "加强干扰文字", + "complexOfNoiseDot": "加强干扰点", + "showHollowLine": "使用空心线", + "showNoiseDot": "使用噪点", + "showNoiseText": "使用干扰文字", + "showSlimeLine": "使用波浪线", + "showSineLine": "使用正弦线", + "siteKey": "Site KEY", + "siteKeyDes": "<0>应用管理页面 获取到的的 网站密钥", + "siteSecret": "Secret", + "siteSecretDes": "<0>应用管理页面 获取到的的 秘钥", + "secretID": "SecretId", + "secretIDDes": "<0>访问密钥页面 获取到的的 SecretId", + "secretKey": "SecretKey", + "secretKeyDes": "<0>访问密钥页面 获取到的的 SecretKey", + "tCaptchaAppID": "APPID", + "tCaptchaAppIDDes": "<0>图形验证页面 获取到的的 APPID", + "tCaptchaSecretKey": "App Secret Key", + "tCaptchaSecretKeyDes": "<0>图形验证页面 获取到的的 App Secret Key" } } \ No newline at end of file diff --git a/src/component/Admin/Setting/Captcha.js b/src/component/Admin/Setting/Captcha.js index 7204910..0634fa2 100644 --- a/src/component/Admin/Setting/Captcha.js +++ b/src/component/Admin/Setting/Captcha.js @@ -14,7 +14,7 @@ import Link from "@material-ui/core/Link"; import { toggleSnackbar } from "../../../redux/explorer"; import FormControlLabel from "@material-ui/core/FormControlLabel"; import Switch from "@material-ui/core/Switch"; -import { useTranslation } from "react-i18next"; +import { Trans, useTranslation } from "react-i18next"; const useStyles = makeStyles((theme) => ({ root: { @@ -101,7 +101,7 @@ export default function Captcha() { options: option, }) .then(() => { - ToggleSnackbar("top", "right", "设置已更改", "success"); + ToggleSnackbar("top", "right", t("saved"), "success"); }) .catch((error) => { ToggleSnackbar("top", "right", error.message, "error"); @@ -124,29 +124,31 @@ export default function Captcha() {
- 验证码 + {t("captcha")}
- 验证码类型 + {t("captchaType")} - 验证码类型 + {t("captchaProvider")}
@@ -156,13 +158,13 @@ export default function Captcha() { {options.captcha_type === "normal" && (
- 普通验证码 + {t("plainCaptchaTitle")}
- 宽度 + {t("captchaWidth")} - 高度 + {t("captchaHeight")} - 长度 + {t("captchaLength")} - 模式 + {t("captchaMode")} - 验证码的形式 + {t("captchaElement")}
{[ { - name: "加强干扰文字", + name: "complexOfNoiseText", field: "captcha_ComplexOfNoiseText", }, { - name: "加强干扰点", + name: "complexOfNoiseDot", field: "captcha_ComplexOfNoiseDot", }, { - name: "使用空心线", + name: "showHollowLine", field: "captcha_IsShowHollowLine", }, { - name: "使用噪点", + name: "showNoiseDot", field: "captcha_IsShowNoiseDot", }, { - name: "使用干扰文字", + name: "showNoiseText", field: "captcha_IsShowNoiseText", }, { - name: "使用波浪线", + name: "showSlimeLine", field: "captcha_IsShowSlimeLine", }, { - name: "使用正弦线", + name: "showSineLine", field: "captcha_IsShowSineLine", }, ].map((input) => ( @@ -282,7 +290,7 @@ export default function Captcha() { )} /> } - label={input.name} + label={t(input.name)} />
@@ -294,14 +302,14 @@ export default function Captcha() { {options.captcha_type === "recaptcha" && (
- reCAPTCHA V2 + {t("reCaptchaV2")}
- Site KEY + {t("siteKey")} - - 应用管理页面 - {" "} - 获取到的的 网站密钥 + , + ]} + />
@@ -327,7 +339,7 @@ export default function Captcha() {
- Secret + {t("siteSecret")} - - 应用管理页面 - {" "} - 获取到的的 秘钥 + components={[ + , + ]} + />
@@ -359,14 +377,14 @@ export default function Captcha() { {options.captcha_type === "tcaptcha" && (
- 腾讯云验证码 + {t("tencentCloudCaptcha")}
- SecretId + {t("secretID")} - - 访问密钥页面 - {" "} - 获取到的的 SecretId + components={[ + , + ]} + />
@@ -394,7 +418,7 @@ export default function Captcha() {
- SecretKey + {t("secretKey")} - - 访问密钥页面 - {" "} - 获取到的的 SecretKey + components={[ + , + ]} + />
@@ -422,7 +452,7 @@ export default function Captcha() {
- APPID + {t("tCaptchaAppID")} - - 图形验证页面 - {" "} - 获取到的的 APPID + components={[ + , + ]} + />
@@ -450,7 +486,7 @@ export default function Captcha() {
- App Secret Key + {t("tCaptchaSecretKey")} - - 图形验证页面 - {" "} - 获取到的的 App Secret Key + components={[ + , + ]} + />
@@ -486,7 +528,7 @@ export default function Captcha() { variant={"contained"} color={"primary"} > - 保存 + {t("save")}