diff --git a/web/src/components/ChangeMemberPasswordDialog.tsx b/web/src/components/ChangeMemberPasswordDialog.tsx index 8777e79d..873961a0 100644 --- a/web/src/components/ChangeMemberPasswordDialog.tsx +++ b/web/src/components/ChangeMemberPasswordDialog.tsx @@ -55,7 +55,7 @@ const ChangeMemberPasswordDialog: React.FC = (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; } diff --git a/web/src/components/ChangePasswordDialog.tsx b/web/src/components/ChangePasswordDialog.tsx index 0b0ca1f2..5cfc884e 100644 --- a/web/src/components/ChangePasswordDialog.tsx +++ b/web/src/components/ChangePasswordDialog.tsx @@ -52,7 +52,7 @@ const ChangePasswordDialog: React.FC = ({ 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; } diff --git a/web/src/components/UpdateAccountDialog.tsx b/web/src/components/UpdateAccountDialog.tsx index a9cdac5b..5591b9ec 100644 --- a/web/src/components/UpdateAccountDialog.tsx +++ b/web/src/components/UpdateAccountDialog.tsx @@ -73,7 +73,7 @@ const UpdateAccountDialog: React.FC = ({ 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; } diff --git a/web/src/helpers/validator.ts b/web/src/helpers/validator.ts index d02ceab6..7844b218 100644 --- a/web/src/helpers/validator.ts +++ b/web/src/helpers/validator.ts @@ -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): { 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): { 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): { 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", }; } diff --git a/web/src/locales/en.json b/web/src/locales/en.json index 3f11e75f..c4ba44b4 100644 --- a/web/src/locales/en.json +++ b/web/src/locales/en.json @@ -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" } } diff --git a/web/src/locales/fr.json b/web/src/locales/fr.json index d3fe83bc..f05f638b 100644 --- a/web/src/locales/fr.json +++ b/web/src/locales/fr.json @@ -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" } } diff --git a/web/src/locales/vi.json b/web/src/locales/vi.json index 35adecdb..c3c810e7 100644 --- a/web/src/locales/vi.json +++ b/web/src/locales/vi.json @@ -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" } } diff --git a/web/src/locales/zh.json b/web/src/locales/zh.json index 95495be6..02e26b2b 100644 --- a/web/src/locales/zh.json +++ b/web/src/locales/zh.json @@ -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": "不允许包含中文" } } diff --git a/web/src/pages/Auth.tsx b/web/src/pages/Auth.tsx index 9661873e..39e68052 100644 --- a/web/src/pages/Auth.tsx +++ b/web/src/pages/Auth.tsx @@ -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; }