chore: update i18n (#215)

This commit is contained in:
ChasLui
2022-09-15 06:53:51 +08:00
committed by GitHub
parent 54db6eda04
commit 7e8d1128f8
15 changed files with 109 additions and 43 deletions

View File

@@ -17,7 +17,7 @@ const validateConfig: ValidatorConfig = {
type Props = DialogProps;
const ChangePasswordDialog: React.FC<Props> = ({ destroy }: Props) => {
const { t } = useI18n();
const { t, locale } = useI18n();
const [newPassword, setNewPassword] = useState("");
const [newPasswordAgain, setNewPasswordAgain] = useState("");
@@ -41,19 +41,19 @@ const ChangePasswordDialog: React.FC<Props> = ({ destroy }: Props) => {
const handleSaveBtnClick = async () => {
if (newPassword === "" || newPasswordAgain === "") {
toastHelper.error("Please fill in all fields.");
toastHelper.error(t("common.fill-all"));
return;
}
if (newPassword !== newPasswordAgain) {
toastHelper.error("New passwords do not match.");
toastHelper.error(t("common.new-password-not-match"));
setNewPasswordAgain("");
return;
}
const passwordValidResult = validate(newPassword, validateConfig);
if (!passwordValidResult.result) {
toastHelper.error("Password " + passwordValidResult.reason);
toastHelper.error(t("common.password") + locale === "zh" ? "" : " " + passwordValidResult.reason);
return;
}
@@ -63,7 +63,7 @@ const ChangePasswordDialog: React.FC<Props> = ({ destroy }: Props) => {
id: user.id,
password: newPassword,
});
toastHelper.info("Password changed.");
toastHelper.info(t("common.password") + t("common.changed"));
handleCloseBtnClick();
} catch (error: any) {
console.error(error);
@@ -74,17 +74,22 @@ const ChangePasswordDialog: React.FC<Props> = ({ destroy }: Props) => {
return (
<>
<div className="dialog-header-container">
<p className="title-text">Change Password</p>
<p className="title-text">{t("common.password" + " " + t("common.change"))}</p>
<button className="btn close-btn" onClick={handleCloseBtnClick}>
<Icon.X />
</button>
</div>
<div className="dialog-content-container">
<label className="form-label input-form-label">
<input type="password" placeholder="New passworld" value={newPassword} onChange={handleNewPasswordChanged} />
<input type="password" placeholder={t("common.new-password")} value={newPassword} onChange={handleNewPasswordChanged} />
</label>
<label className="form-label input-form-label">
<input type="password" placeholder="Repeat the new password" value={newPasswordAgain} onChange={handleNewPasswordAgainChanged} />
<input
type="password"
placeholder={t("common.repeat-new-password")}
value={newPasswordAgain}
onChange={handleNewPasswordAgainChanged}
/>
</label>
<div className="btns-container">
<span className="btn cancel-btn" onClick={handleCloseBtnClick}>