i18n: captcha

This commit is contained in:
HFO4 2022-04-30 16:49:14 +08:00
parent d6dc1f9719
commit 1afc064d7a
6 changed files with 13 additions and 5 deletions

View File

@ -3,6 +3,7 @@
"email": "Email",
"password": "Password",
"captcha": "CAPTCHA",
"captchaError": "Cannot load CAPTCHA: {{message}}",
"signIn": "Sign in",
"signUp": "Sign up",
"signUpAccount": "Sign up",

View File

@ -13,6 +13,8 @@
"40001": "Wrong format of input parameters ({{message}})",
"40021": "User not found",
"40022": "Verification code not correct",
"40023": "Login session not exist"
"40023": "Login session not exist",
"40024": "Cannot initialize WebAuthn",
"40025": "Authentication failed"
}
}

View File

@ -3,6 +3,7 @@
"email": "电子邮箱",
"password": "密码",
"captcha": "验证码",
"captchaError": "Cannot load CAPTCHA: {{message}}",
"signIn": "登录",
"signUp": "注册",
"signUpAccount": "注册账号",

View File

@ -13,6 +13,8 @@
"40001": "输入参数格式有误 ({{message}})",
"40021": "用户不存在",
"40022": "验证代码不正确",
"40023": "登录会话不存在"
"40023": "登录会话不存在",
"40024": "无法初始化 WebAuthn",
"40025": "验证失败"
}
}

View File

@ -11,11 +11,13 @@ import { FormControl, Input, InputLabel } from "@material-ui/core";
import Placeholder from "../component/Placeholder/Captcha";
import { defaultValidate, useStyle } from "./useCaptcha";
import { toggleSnackbar } from "../redux/explorer";
import { useTranslation } from "react-i18next";
const NormalCaptcha = forwardRef(function NormalCaptcha(
{ captchaRef, setLoading },
ref
) {
const { t } = useTranslation();
const classes = useStyle();
const [captcha, setCaptcha] = useState("");
@ -38,7 +40,7 @@ const NormalCaptcha = forwardRef(function NormalCaptcha(
ToggleSnackbar(
"top",
"right",
"无法加载验证码:" + error.message,
t("login.captchaError", { message: error.message }),
"error"
);
});
@ -56,7 +58,7 @@ const NormalCaptcha = forwardRef(function NormalCaptcha(
return (
<div className={classes.captchaContainer}>
<FormControl margin="normal" required fullWidth>
<InputLabel htmlFor="captcha">验证码</InputLabel>
<InputLabel htmlFor="captcha">{t("login.captcha")}</InputLabel>
<Input
name="captcha"
onChange={(e) => setCaptcha(e.target.value)}

View File

@ -45,7 +45,7 @@ class AppError extends Error {
message || i18next.t("unknownError", { ns: "common" });
}
this.message += error ? " " + error : "";
this.message += error ? ` (${error})` : "";
this.stack = new Error().stack;
}
}