Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore: update i18n for validator message (#636)
Zeng199852038d26d261
diff --git a/web/src/components/ChangeMemberPasswordDialog.tsx b/web/src/components/ChangeMemberPasswordDialog.tsxindex 8777e79d5..873961a01 100644--- a/web/src/components/ChangeMemberPasswordDialog.tsx+++ b/web/src/components/ChangeMemberPasswordDialog.tsx@@ -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;}diff --git a/web/src/components/ChangePasswordDialog.tsx b/web/src/components/ChangePasswordDialog.tsxindex 0b0ca1f21..5cfc884ee 100644--- a/web/src/components/ChangePasswordDialog.tsx+++ b/web/src/components/ChangePasswordDialog.tsx@@ -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;}diff --git a/web/src/components/UpdateAccountDialog.tsx b/web/src/components/UpdateAccountDialog.tsxindex a9cdac5bf..5591b9ec8 100644--- a/web/src/components/UpdateAccountDialog.tsx+++ b/web/src/components/UpdateAccountDialog.tsx@@ -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;}diff --git a/web/src/helpers/validator.ts b/web/src/helpers/validator.tsindex d02ceab6e..7844b218e 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<ValidatorConfig>): { resuif (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>): { resuif (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>): { resuif (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.jsonindex 3f11e75fe..c4ba44b43 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.jsonindex d3fe83bc2..f05f638bf 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.jsonindex 35adecdbc..c3c810e78 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.jsonindex 95495be63..02e26b2b0 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.tsxindex 9661873e2..39e68052a 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;}