diff --git a/public/locales/en-US/application.json b/public/locales/en-US/application.json index 236e5a3..31d7454 100644 --- a/public/locales/en-US/application.json +++ b/public/locales/en-US/application.json @@ -12,9 +12,18 @@ "forgetPassword": "Forgot password?", "2FA": "2FA Verification", "input2FACode": "Please enter the six-digit 2FA verification code", - "browserNotSupport": "Not supported by current browser or environment", + "passwordNotMatch": "Those passwords didn’t match.", + "findMyPassword": "Find my password", + "passwordReset": "Password has been reset.", + "newPassword": "New password", + "repeatNewPassword": "Repeat the password", + "resetPassword": "Reset my password", + "backToSingIn": "Back to sign in", + "sendMeAnEmail": "Send me an email", + "resetEmailSent": "An email has been sent, please pay attention to check.", + "browserNotSupport": "Not supported by current browser or environment.", "success": "Sign in successful", - "title": "Sign in {{title}}", - "continue": "Continue" + "title": "Sign in to {{title}}", + "continue": "Next" } } \ No newline at end of file diff --git a/public/locales/en-US/common.json b/public/locales/en-US/common.json index 578441e..68844fa 100644 --- a/public/locales/en-US/common.json +++ b/public/locales/en-US/common.json @@ -6,15 +6,21 @@ "errorDetails": "Error details", "renderError": "There is an error in the page rendering, please try refreshing this page.", "errors": { - "40020": "Wrong password or email address", - "40017": "This account has been blocked", - "40018": "This account is not activated", - "40019": "This feature is not enabled", - "40001": "Wrong format of input parameters ({{message}})", - "40021": "User not found", - "40022": "Verification code not correct", - "40023": "Login session not exist", - "40024": "Cannot initialize WebAuthn", - "40025": "Authentication failed" + "40020": "Wrong password or email address.", + "40017": "This account has been blocked.", + "40018": "This account is not activated.", + "40019": "This feature is not enabled.", + "40001": "Wrong format of input parameters ({{message}}).", + "40021": "User not found.", + "40022": "Verification code not correct.", + "40023": "Login session not exist.", + "40024": "Cannot initialize WebAuthn.", + "40025": "Authentication failed.", + "40026": "CAPTCHA code is not correct.", + "40027": "Verification failed, please refresh the page and retry.", + "40028": "Mail delivery failed.", + "40029": "This link is invalid.", + "40030": "This link is expired.", + "50001": "Database operation failed. ({{message}})" } } \ No newline at end of file diff --git a/public/locales/zh-CN/application.json b/public/locales/zh-CN/application.json index dd57017..bd48736 100644 --- a/public/locales/zh-CN/application.json +++ b/public/locales/zh-CN/application.json @@ -3,7 +3,7 @@ "email": "电子邮箱", "password": "密码", "captcha": "验证码", - "captchaError": "Cannot load CAPTCHA: {{message}}", + "captchaError": "验证码加载失败: {{message}}", "signIn": "登录", "signUp": "注册", "signUpAccount": "注册账号", @@ -12,6 +12,15 @@ "forgetPassword": "忘记密码", "2FA": "二步验证", "input2FACode": "请输入六位二步验证代码", + "passwordNotMatch": "两次密码输入不一致", + "findMyPassword": "找回密码", + "passwordReset": "密码已重设", + "newPassword": "新密码", + "repeatNewPassword": "重复新密码", + "resetPassword": "重设密码", + "backToSingIn": "返回登陆", + "sendMeAnEmail": "发送密码重置邮件", + "resetEmailSent": "密码重置邮件已发送,请注意查收", "browserNotSupport": "当前浏览器或环境不支持", "success": "登录成功", "title": "登录 {{title}}", diff --git a/public/locales/zh-CN/common.json b/public/locales/zh-CN/common.json index 572d5d3..70ce7ee 100644 --- a/public/locales/zh-CN/common.json +++ b/public/locales/zh-CN/common.json @@ -2,8 +2,8 @@ "pageNotFound": "页面不存在", "unknownError": "未知错误", "errLoadingSiteConfig": "无法加载站点配置:", - "errorDetails": "错误详情", "newVersionRefresh": "当前页面有新版本可用,准备刷新。", + "errorDetails": "错误详情", "renderError": "页面渲染出现错误,请尝试刷新此页面。", "errors": { "40020": "用户邮箱或密码错误", @@ -15,6 +15,12 @@ "40022": "验证代码不正确", "40023": "登录会话不存在", "40024": "无法初始化 WebAuthn", - "40025": "验证失败" + "40025": "验证失败", + "40026": "验证码错误", + "40027": "验证失败,请刷新网页重试", + "40028": "邮件发送失败", + "40029": "无效的链接", + "40030": "此链接已过期", + "50001": "数据库操作失败 ({{message}})" } } \ No newline at end of file diff --git a/src/component/Login/Reset.js b/src/component/Login/Reset.js index c8e9475..becfd73 100644 --- a/src/component/Login/Reset.js +++ b/src/component/Login/Reset.js @@ -16,6 +16,8 @@ import API from "../../middleware/Api"; import KeyIcon from "@material-ui/icons/VpnKeyOutlined"; import { useCaptcha } from "../../hooks/useCaptcha"; import { toggleSnackbar } from "../../redux/explorer"; +import { useTranslation } from "react-i18next"; +import { Link as RouterLink } from "react-router-dom"; const useStyles = makeStyles((theme) => ({ layout: { @@ -62,12 +64,18 @@ const useStyles = makeStyles((theme) => ({ })); function Reset() { + const { t } = useTranslation(); + const [input, setInput] = useState({ email: "", }); const [loading, setLoading] = useState(false); - const forgetCaptcha = useSelector((state) => state.siteConfig.forgetCaptcha); - const registerEnabled = useSelector((state) => state.siteConfig.registerEnabled); + const forgetCaptcha = useSelector( + (state) => state.siteConfig.forgetCaptcha + ); + const registerEnabled = useSelector( + (state) => state.siteConfig.registerEnabled + ); const dispatch = useDispatch(); const ToggleSnackbar = useCallback( (vertical, horizontal, msg, color) => @@ -106,7 +114,7 @@ function Reset() { ToggleSnackbar( "top", "right", - "密码重置邮件已发送,请注意查收", + t("login.resetEmailSent"), "success" ); }) @@ -126,11 +134,13 @@ function Reset() { - 找回密码 + {t("login.findMyPassword")}
- 注册邮箱 + + {t("login.email")} + - 发送密码重置邮件 + {t("login.sendMeAnEmail")} {" "} {" "}
- 返回登录 + + {t("login.backToSingIn")} + +
+
+ {registerEnabled && ( + + {t("login.signUpAccount")} + + )}
- { registerEnabled && ( -
- 注册账号 -
- )}
diff --git a/src/component/Login/ResetForm.js b/src/component/Login/ResetForm.js index 1dfee97..4e67620 100644 --- a/src/component/Login/ResetForm.js +++ b/src/component/Login/ResetForm.js @@ -1,22 +1,24 @@ import React, { useCallback, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; -import { makeStyles } from "@material-ui/core"; -import { useHistory } from "react-router-dom"; -import API from "../../middleware/Api"; import { + Avatar, Button, - FormControl, Divider, - Link, + FormControl, Input, InputLabel, + Link, + makeStyles, Paper, - Avatar, Typography, } from "@material-ui/core"; +import { Link as RouterLink, useHistory } from "react-router-dom"; +import API from "../../middleware/Api"; import { useLocation } from "react-router"; import KeyIcon from "@material-ui/icons/VpnKeyOutlined"; import { toggleSnackbar } from "../../redux/explorer"; +import { useTranslation } from "react-i18next"; + const useStyles = makeStyles((theme) => ({ layout: { width: "auto", @@ -59,13 +61,16 @@ function useQuery() { } function ResetForm() { + const { t } = useTranslation(); const query = useQuery(); const [input, setInput] = useState({ password: "", password_repeat: "", }); const [loading, setLoading] = useState(false); - const registerEnabled = useSelector((state) => state.siteConfig.registerEnabled); + const registerEnabled = useSelector( + (state) => state.siteConfig.registerEnabled + ); const handleInputChange = (name) => (e) => { setInput({ ...input, @@ -83,7 +88,12 @@ function ResetForm() { const submit = (e) => { e.preventDefault(); if (input.password !== input.password_repeat) { - ToggleSnackbar("top", "right", "两次密码输入不一致", "warning"); + ToggleSnackbar( + "top", + "right", + t("login.passwordNotMatch"), + "warning" + ); return; } setLoading(true); @@ -95,7 +105,12 @@ function ResetForm() { .then(() => { setLoading(false); history.push("/login"); - ToggleSnackbar("top", "right", "密码已重设", "success"); + ToggleSnackbar( + "top", + "right", + t("login.passwordReset"), + "success" + ); }) .catch((error) => { setLoading(false); @@ -112,11 +127,13 @@ function ResetForm() { - 找回密码 + {t("login.findMyPassword")}
- 新密码 + + {t("login.newPassword")} + - 重复新密码 + + {t("login.repeatNewPassword")} + - 重设密码 + {t("login.resetPassword")} {" "} {" "}
- 返回登录 + + {t("login.backToSingIn")} + +
+
+ {registerEnabled && ( + + {t("login.signUpAccount")} + + )}
- { registerEnabled && ( -
- 注册账号 -
- )}