From c0f8a7ef6ddd335b697347dce56271c3d3d8c215 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Wed, 25 May 2022 19:59:33 +0800 Subject: [PATCH] i18n: basic setting and public access setting in dashboard --- public/locales/en-US/dashboard.json | 45 ++++++++++++ public/locales/zh-CN/dashboard.json | 44 +++++++++++- src/component/Admin/Setting/Access.js | 44 ++++++------ .../Admin/Setting/SiteInformation.js | 70 ++++++++----------- 4 files changed, 138 insertions(+), 65 deletions(-) diff --git a/public/locales/en-US/dashboard.json b/public/locales/en-US/dashboard.json index 765d1e0..b892f8a 100644 --- a/public/locales/en-US/dashboard.json +++ b/public/locales/en-US/dashboard.json @@ -44,5 +44,50 @@ "buyPro": "Upgrade to Pro", "publishedAt": "published at <0>", "newsTag": "announcements" + }, + "settings": { + "saved": "Settings saved.", + "save": "Save", + "basicInformation": "Basic information", + "mainTitle": "Main title", + "mainTitleDes": "Main title of the website.", + "subTitle": "Subtitle", + "subTitleDes": "Subtitle of the website.", + "siteDescription": "Site description", + "siteDescriptionDes": "Description of the website, which may be displayed in the shared page summary.", + "siteURL": "Site URL", + "siteURLDes": "Very important, please make sure it is consistent with the actual situation. When using cloud storage policy and payment platform, please fill in the address that can be accessed by WAN.", + "customFooterHTML": "Custom footer HTML", + "customFooterHTMLDes": "Custom HTML code inserted at the bottom of the page.", + "pwa": "Progressive Web Application (PWA)", + "smallIcon": "Small icon", + "smallIconDes": "URL of the small icon with the ico as extension", + "mediumIcon": "Medium icon", + "mediumIconDes": "URL of the medium icon, prefer size at 192x192, png format.", + "largeIcon": "Large icon", + "largeIconDes": "URL of the medium icon, prefer size at 512x512, png format.", + "displayMode": "Display mode", + "displayModeDes": "The display mode of a PWA application after it's installed.", + "themeColor": "Theme color", + "themeColorDes": "CSS color value that affect the color of the status bar on the PWA launch screen, the status bar in the content page, and the address bar.", + "backgroundColor": "Background color", + "backgroundColorDes": "CSS color value.", + "hint": "Hint", + "webauthnNoHttps": "Web Authn requires your website to be HTTPS enabled, and please confirm that in Settings - Basic - Site URL also uses HTTPS.", + "accountManagement": "Accounts", + "allowNewRegistrations": "Accept new signups", + "allowNewRegistrationsDes": "After disabled, no new users can be registered, unless manually added by admins.", + "emailActivation": "Email activation", + "emailActivationDes": "After enabled, new users need to click the activation link in the email to complete signups. Please make sure the email delivery settings are correct, otherwise the activation email will not be delivered.", + "captchaForSignup": "Captcha for signups", + "captchaForSignupDes": "Whether to enable the captcha for signups.", + "captchaForLogin": "Captcha for logins", + "captchaForLoginDes": "Whether to enable the captcha for logins.", + "captchaForReset": "Captcha for resetting password", + "captchaForResetDes": "Whether to enable the captcha for resetting password.", + "webauthnDes": "Whether to allow users to log in using a hardware authenticator, the website must enable HTTPS for this to work.", + "webauthn": "Hardware authenticator", + "defaultGroup": "Default group", + "defaultGroupDes": "The initial user group after user registration." } } \ No newline at end of file diff --git a/public/locales/zh-CN/dashboard.json b/public/locales/zh-CN/dashboard.json index ba7d20a..d3e09c1 100644 --- a/public/locales/zh-CN/dashboard.json +++ b/public/locales/zh-CN/dashboard.json @@ -46,6 +46,48 @@ "newsTag": "notice" }, "settings": { - "saved": "设置已更改" + "saved": "设置已更改", + "save": "保存", + "basicInformation": "基本信息", + "mainTitle": "主标题", + "mainTitleDes": "站点的主标题", + "subTitle": "副标题", + "subTitleDes": "站点的副标题", + "siteDescription": "站点描述", + "siteDescriptionDes": "站点描述信息,可能会在分享页面摘要内展示", + "siteURL": "站点 URL", + "siteURLDes": "非常重要,请确保与实际情况一致。使用云存储策略、支付平台时,请填入可以被外网访问的地址", + "customFooterHTML": "页脚代码", + "customFooterHTMLDes": "在页面底部插入的自定义 HTML 代码", + "pwa": "渐进式应用 (PWA)", + "smallIcon": "小图标", + "smallIconDes": "扩展名为 ico 的小图标地址", + "mediumIcon": "中图标", + "mediumIconDes": "192x192 的中等图标地址,png 格式", + "largeIcon": "大图标", + "largeIconDes": "512x512 的大图标地址,png 格式", + "displayMode": "展示模式", + "displayModeDes": "PWA 应用添加后的展示模式", + "themeColor": "主题色", + "themeColorDes": "CSS 色值,影响 PWA 启动画面上状态栏、内容页中状态栏、地址栏的颜色", + "backgroundColor": "背景色", + "backgroundColorDes": "CSS 色值", + "hint": "提示", + "webauthnNoHttps": "Web Authn 需要您的站点启用 HTTPS,并确认 参数设置 - 站点信息 - 站点URL 也使用了 HTTPS 后才能开启。", + "accountManagement": "注册与登录", + "allowNewRegistrations": "允许新用户注册", + "allowNewRegistrationsDes": "关闭后,无法再通过前台注册新的用户", + "emailActivation": "邮件激活", + "emailActivationDes": "开启后,新用户注册需要点击邮件中的激活链接才能完成。请确认邮件发送设置是否正确,否则激活邮件无法送达。", + "captchaForSignup": "注册验证码", + "captchaForSignupDes": "是否启用注册表单验证码", + "captchaForLogin": "登录验证码", + "captchaForLoginDes": "是否启用登录表单验证码", + "captchaForReset": "找回密码验证码", + "captchaForResetDes": "是否启用找回密码表单验证码", + "webauthnDes": "是否允许用户使用绑定的外部验证器登录,站点必须启动 HTTPS 才能使用。", + "webauthn": "外部验证器登录", + "defaultGroup": "默认用户组", + "defaultGroupDes": "用户注册后的初始用户组" } } \ No newline at end of file diff --git a/src/component/Admin/Setting/Access.js b/src/component/Admin/Setting/Access.js index 9bb0891..85c9419 100644 --- a/src/component/Admin/Setting/Access.js +++ b/src/component/Admin/Setting/Access.js @@ -13,6 +13,7 @@ import { useDispatch } from "react-redux"; import { toggleSnackbar } from "../../../redux/explorer"; import API from "../../../middleware/Api"; import AlertDialog from "../Dialogs/Alert"; +import { useTranslation } from "react-i18next"; const useStyles = makeStyles((theme) => ({ root: { @@ -34,6 +35,8 @@ const useStyles = makeStyles((theme) => ({ })); export default function Access() { + const { t } = useTranslation("dashboard", { keyPrefix: "settings" }); + const { t: tVas } = useTranslation("dashboard", { keyPrefix: "vas" }); const classes = useStyles(); const [loading, setLoading] = useState(false); const [options, setOptions] = useState({ @@ -112,7 +115,7 @@ export default function Access() { options: option, }) .then(() => { - ToggleSnackbar("top", "right", "设置已更改", "success"); + ToggleSnackbar("top", "right", t("saved"), "success"); }) .catch((error) => { ToggleSnackbar("top", "right", error.message, "error"); @@ -125,17 +128,15 @@ export default function Access() { return (
setHttpAlert(false)} open={httpAlert} />
- 注册与登录 + {t("accountManagement")}
@@ -151,10 +152,10 @@ export default function Access() { )} /> } - label="允许新用户注册" + label={t("allowNewRegistrations")} /> - 关闭后,无法再通过前台注册新的用户 + {t("allowNewRegistrationsDes")}
@@ -172,10 +173,10 @@ export default function Access() { )} /> } - label="邮件激活" + label={t("emailActivation")} /> - 开启后,新用户注册需要点击邮件中的激活链接才能完成。请确认邮件发送设置是否正确,否则激活邮件无法送达 + {t("emailActivationDes")}
@@ -193,10 +194,10 @@ export default function Access() { )} /> } - label="注册验证码" + label={t("captchaForSignup")} /> - 是否启用注册表单验证码 + {t("captchaForSignupDes")}
@@ -214,10 +215,10 @@ export default function Access() { )} /> } - label="登录验证码" + label={t("captchaForLogin")} /> - 是否启用登录表单验证码 + {t("captchaForLoginDes")}
@@ -235,10 +236,10 @@ export default function Access() { )} /> } - label="找回密码验证码" + label={t("captchaForReset")} /> - 是否启用找回密码表单验证码 + {t("captchaForResetDes")} @@ -266,11 +267,10 @@ export default function Access() { }} /> } - label="Web Authn" + label={t("webauthn")} /> - 是否允许用户使用绑定的外部验证器登录,站点必须启动 - HTTPS 才能使用。 + {t("webauthnDes")} @@ -278,7 +278,7 @@ export default function Access() {
- 默认用户组 + {t("defaultGroup")} - 站点的主标题 + {t("mainTitleDes")}
- 副标题 + {t("subTitle")} - 站点的副标题 + {t("subTitleDes")}
- 站点描述 + {t("siteDescription")} - 站点描述信息,可能会在分享页面摘要内展示 + {t("siteDescriptionDes")}
- 站点URL + {t("siteURL")} - 非常重要,请确保与实际情况一致。使用云存储策略、支付平台时,请填入可以被外网访问的地址。 + {t("siteURLDes")}
- 网站备案号 - - - - 工信部网站ICP备案号 - - -
-
- - - 页脚代码 + {t("customFooterHTML")} - 在页面底部插入的自定义HTML代码 + {t("customFooterHTMLDes")}
@@ -200,55 +187,55 @@ export default function SiteInformation() {
- 渐进式应用 (PWA) + {t("pwa")}
- 小图标 + {t("smallIcon")} - 扩展名为 ico 的小图标地址 + {t("smallIconDes")}
- 中图标 + {t("mediumIcon")} - 192x192 的中等图标地址,png 格式 + {t("mediumIconDes")}
- 大图标 + {t("largeIcon")} - 512x512 的大图标地址,png 格式 + {t("largeIconDes")}
- 展示模式 + {t("displayMode")} - PWA 应用添加后的展示模式 + {t("displayModeDes")}
- 主题色 + {t("themeColor")} - CSS 色值,影响 PWA - 启动画面上状态栏、内容页中状态栏、地址栏的颜色 + {t("themeColorDes")}
@@ -292,7 +278,7 @@ export default function SiteInformation() {
- 背景色 + {t("backgroundColor")} - CSS 色值 + {t("backgroundColorDes")}
@@ -314,7 +300,7 @@ export default function SiteInformation() { variant={"contained"} color={"primary"} > - 保存 + {t("save")}