mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: update i18n for validator message (#636)
This commit is contained in:
@ -55,7 +55,7 @@ const ChangeMemberPasswordDialog: React.FC<Props> = (props: Props) => {
|
|||||||
|
|
||||||
const passwordValidResult = validate(newPassword, validateConfig);
|
const passwordValidResult = validate(newPassword, validateConfig);
|
||||||
if (!passwordValidResult.result) {
|
if (!passwordValidResult.result) {
|
||||||
toastHelper.error(`${t("common.password")} ${passwordValidResult.reason}`);
|
toastHelper.error(`${t("common.password")} ${t(passwordValidResult.reason as string)}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ const ChangePasswordDialog: React.FC<Props> = ({ destroy }: Props) => {
|
|||||||
|
|
||||||
const passwordValidResult = validate(newPassword, validateConfig);
|
const passwordValidResult = validate(newPassword, validateConfig);
|
||||||
if (!passwordValidResult.result) {
|
if (!passwordValidResult.result) {
|
||||||
toastHelper.error(`${t("common.password")} ${passwordValidResult.reason}`);
|
toastHelper.error(`${t("common.password")} ${t(passwordValidResult.reason as string)}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ const UpdateAccountDialog: React.FC<Props> = ({ destroy }: Props) => {
|
|||||||
|
|
||||||
const usernameValidResult = validate(state.username, validateConfig);
|
const usernameValidResult = validate(state.username, validateConfig);
|
||||||
if (!usernameValidResult.result) {
|
if (!usernameValidResult.result) {
|
||||||
toastHelper.error(t("common.username") + ": " + usernameValidResult.reason);
|
toastHelper.error(t("common.username") + ": " + t(usernameValidResult.reason as string));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// Validator
|
// Validator
|
||||||
// * use for validating form data
|
// * use for validating form data
|
||||||
|
|
||||||
const chineseReg = /[\u3000\u3400-\u4DBF\u4E00-\u9FFF]/;
|
const chineseReg = /[\u3000\u3400-\u4DBF\u4E00-\u9FFF]/;
|
||||||
|
|
||||||
export interface ValidatorConfig {
|
export interface ValidatorConfig {
|
||||||
@ -18,7 +19,7 @@ export function validate(text: string, config: Partial<ValidatorConfig>): { resu
|
|||||||
if (text.length < config.minLength) {
|
if (text.length < config.minLength) {
|
||||||
return {
|
return {
|
||||||
result: false,
|
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) {
|
if (text.length > config.maxLength) {
|
||||||
return {
|
return {
|
||||||
result: false,
|
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(" ")) {
|
if (config.noSpace && text.includes(" ")) {
|
||||||
return {
|
return {
|
||||||
result: false,
|
result: false,
|
||||||
reason: "Don't allow space",
|
reason: "message.not-allow-space",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.noChinese && chineseReg.test(text)) {
|
if (config.noChinese && chineseReg.test(text)) {
|
||||||
return {
|
return {
|
||||||
result: false,
|
result: false,
|
||||||
reason: "Don't allow chinese",
|
reason: "message.not-allow-chinese",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,6 +203,11 @@
|
|||||||
"resource-filename-updated": "Resource filename changed.",
|
"resource-filename-updated": "Resource filename changed.",
|
||||||
"invalid-resource-filename": "Invalid filename.",
|
"invalid-resource-filename": "Invalid filename.",
|
||||||
"click-to-save-the-image": "Click to save the image",
|
"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é.",
|
"resource-filename-updated": "Le nom de fichier de la ressource a changé.",
|
||||||
"invalid-resource-filename": "Nom de fichier invalide.",
|
"invalid-resource-filename": "Nom de fichier invalide.",
|
||||||
"click-to-save-the-image": "Cliquez pour enregistrer l'image",
|
"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.",
|
"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ệ.",
|
"invalid-resource-filename": "Tên tệp không hợp lệ.",
|
||||||
"click-to-save-the-image": "Bấm để lưu hình ảnh",
|
"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": "资源文件名更改成功。",
|
"resource-filename-updated": "资源文件名更改成功。",
|
||||||
"invalid-resource-filename": "无效的资源文件名",
|
"invalid-resource-filename": "无效的资源文件名",
|
||||||
"click-to-save-the-image": "点击保存图片",
|
"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);
|
const usernameValidResult = validate(username, validateConfig);
|
||||||
if (!usernameValidResult.result) {
|
if (!usernameValidResult.result) {
|
||||||
toastHelper.error(t("common.username") + ": " + usernameValidResult.reason);
|
toastHelper.error(t("common.username") + ": " + t(usernameValidResult.reason as string));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const passwordValidResult = validate(password, validateConfig);
|
const passwordValidResult = validate(password, validateConfig);
|
||||||
if (!passwordValidResult.result) {
|
if (!passwordValidResult.result) {
|
||||||
toastHelper.error(t("common.password") + ": " + passwordValidResult.reason);
|
toastHelper.error(t("common.password") + ": " + t(passwordValidResult.reason as string));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,13 +82,13 @@ const Auth = () => {
|
|||||||
|
|
||||||
const usernameValidResult = validate(username, validateConfig);
|
const usernameValidResult = validate(username, validateConfig);
|
||||||
if (!usernameValidResult.result) {
|
if (!usernameValidResult.result) {
|
||||||
toastHelper.error(t("common.username") + ": " + usernameValidResult.reason);
|
toastHelper.error(t("common.username") + ": " + t(usernameValidResult.reason as string));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const passwordValidResult = validate(password, validateConfig);
|
const passwordValidResult = validate(password, validateConfig);
|
||||||
if (!passwordValidResult.result) {
|
if (!passwordValidResult.result) {
|
||||||
toastHelper.error(t("common.password") + ": " + passwordValidResult.reason);
|
toastHelper.error(t("common.password") + ": " + t(passwordValidResult.reason as string));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user