chore: update i18n for validator message (#636)

pull/639/head
Zeng1998 2 years ago committed by GitHub
parent 55f37664ef
commit 52038d26d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -55,7 +55,7 @@ const ChangeMemberPasswordDialog: React.FC<Props> = (props: Props) => {
const passwordValidResult = validate(newPassword, validateConfig);
if (!passwordValidResult.result) {
toastHelper.error(`${t("common.password")} ${passwordValidResult.reason}`);
toastHelper.error(`${t("common.password")} ${t(passwordValidResult.reason as string)}`);
return;
}

@ -52,7 +52,7 @@ const ChangePasswordDialog: React.FC<Props> = ({ destroy }: Props) => {
const passwordValidResult = validate(newPassword, validateConfig);
if (!passwordValidResult.result) {
toastHelper.error(`${t("common.password")} ${passwordValidResult.reason}`);
toastHelper.error(`${t("common.password")} ${t(passwordValidResult.reason as string)}`);
return;
}

@ -73,7 +73,7 @@ const UpdateAccountDialog: React.FC<Props> = ({ destroy }: Props) => {
const usernameValidResult = validate(state.username, validateConfig);
if (!usernameValidResult.result) {
toastHelper.error(t("common.username") + ": " + usernameValidResult.reason);
toastHelper.error(t("common.username") + ": " + t(usernameValidResult.reason as string));
return;
}

@ -1,5 +1,6 @@
// Validator
// * use for validating form data
const chineseReg = /[\u3000\u3400-\u4DBF\u4E00-\u9FFF]/;
export interface ValidatorConfig {
@ -18,7 +19,7 @@ export function validate(text: string, config: Partial<ValidatorConfig>): { resu
if (text.length < config.minLength) {
return {
result: false,
reason: "Too short",
reason: "message.too-short",
};
}
}
@ -27,7 +28,7 @@ export function validate(text: string, config: Partial<ValidatorConfig>): { resu
if (text.length > config.maxLength) {
return {
result: false,
reason: "Too long",
reason: "message.too-long",
};
}
}
@ -35,14 +36,14 @@ export function validate(text: string, config: Partial<ValidatorConfig>): { resu
if (config.noSpace && text.includes(" ")) {
return {
result: false,
reason: "Don't allow space",
reason: "message.not-allow-space",
};
}
if (config.noChinese && chineseReg.test(text)) {
return {
result: false,
reason: "Don't allow chinese",
reason: "message.not-allow-chinese",
};
}

@ -203,6 +203,11 @@
"resource-filename-updated": "Resource filename changed.",
"invalid-resource-filename": "Invalid filename.",
"click-to-save-the-image": "Click to save the image",
"generating-the-screenshot": "Generating the screenshot..."
"generating-the-screenshot": "Generating the screenshot...",
"count-selected-resources": "Total selected",
"too-short": "Too short",
"too-long": "Too long",
"not-allow-space": "Don't allow space",
"not-allow-chinese": "Don't allow chinese"
}
}

@ -198,6 +198,11 @@
"resource-filename-updated": "Le nom de fichier de la ressource a changé.",
"invalid-resource-filename": "Nom de fichier invalide.",
"click-to-save-the-image": "Cliquez pour enregistrer l'image",
"generating-the-screenshot": "Génération de la capture d'écran..."
"generating-the-screenshot": "Génération de la capture d'écran...",
"count-selected-resources": "Total selected",
"too-short": "Too short",
"too-long": "Too long",
"not-allow-space": "Don't allow space",
"not-allow-chinese": "Don't allow chinese"
}
}

@ -197,6 +197,11 @@
"resource-filename-updated": "Tên tệp tài nguyên đã thay đổi.",
"invalid-resource-filename": "Tên tệp không hợp lệ.",
"click-to-save-the-image": "Bấm để lưu hình ảnh",
"generating-the-screenshot": "Đang tạo ảnh chụp màn hình ..."
"generating-the-screenshot": "Đang tạo ảnh chụp màn hình ...",
"count-selected-resources": "Total selected",
"too-short": "Too short",
"too-long": "Too long",
"not-allow-space": "Don't allow space",
"not-allow-chinese": "Don't allow chinese"
}
}

@ -203,6 +203,11 @@
"resource-filename-updated": "资源文件名更改成功。",
"invalid-resource-filename": "无效的资源文件名",
"click-to-save-the-image": "点击保存图片",
"generating-the-screenshot": "正在生成图片..."
"generating-the-screenshot": "正在生成图片...",
"count-selected-resources": "所选资源总数",
"too-short": "过短",
"too-long": "过长",
"not-allow-space": "不允许包含空格",
"not-allow-chinese": "不允许包含中文"
}
}

@ -49,13 +49,13 @@ const Auth = () => {
const usernameValidResult = validate(username, validateConfig);
if (!usernameValidResult.result) {
toastHelper.error(t("common.username") + ": " + usernameValidResult.reason);
toastHelper.error(t("common.username") + ": " + t(usernameValidResult.reason as string));
return;
}
const passwordValidResult = validate(password, validateConfig);
if (!passwordValidResult.result) {
toastHelper.error(t("common.password") + ": " + passwordValidResult.reason);
toastHelper.error(t("common.password") + ": " + t(passwordValidResult.reason as string));
return;
}
@ -82,13 +82,13 @@ const Auth = () => {
const usernameValidResult = validate(username, validateConfig);
if (!usernameValidResult.result) {
toastHelper.error(t("common.username") + ": " + usernameValidResult.reason);
toastHelper.error(t("common.username") + ": " + t(usernameValidResult.reason as string));
return;
}
const passwordValidResult = validate(password, validateConfig);
if (!passwordValidResult.result) {
toastHelper.error(t("common.password") + ": " + passwordValidResult.reason);
toastHelper.error(t("common.password") + ": " + t(passwordValidResult.reason as string));
return;
}

Loading…
Cancel
Save