From 85234b21c723650ba2ef964296ddee5fc5c51c16 Mon Sep 17 00:00:00 2001 From: Elvis Liao Date: Sun, 29 Sep 2024 20:43:42 +0800 Subject: [PATCH 1/2] chore: translate local deployment form --- .../components/certimate/AccessLocalForm.tsx | 34 ++++++++++--------- ui/src/components/certimate/AccessSSHForm.tsx | 9 +++-- ui/src/domain/access.ts | 2 +- ui/src/domain/domain.ts | 2 +- ui/src/i18n/locales/en.json | 12 ++++--- ui/src/i18n/locales/zh.json | 12 ++++--- 6 files changed, 38 insertions(+), 33 deletions(-) diff --git a/ui/src/components/certimate/AccessLocalForm.tsx b/ui/src/components/certimate/AccessLocalForm.tsx index 2befd418..8637e25f 100644 --- a/ui/src/components/certimate/AccessLocalForm.tsx +++ b/ui/src/components/certimate/AccessLocalForm.tsx @@ -9,6 +9,7 @@ import { useConfig } from "@/providers/config"; import { zodResolver } from "@hookform/resolvers/zod"; import { useForm } from "react-hook-form"; import { z } from "zod"; +import { useTranslation } from "react-i18next"; import { Form, FormControl, @@ -32,15 +33,16 @@ const AccessLocalForm = ({ onAfterReq: () => void; }) => { const { addAccess, updateAccess, reloadAccessGroups } = useConfig(); + const { t } = useTranslation(); const formSchema = z.object({ id: z.string().optional(), - name: z.string().min(1).max(64), + name: z.string().min(1, 'access.form.name.not.empty').max(64, t('zod.rule.string.max', { max: 64 })), configType: accessFormType, - command: z.string().min(1).max(2048), - certPath: z.string().min(0).max(2048), - keyPath: z.string().min(0).max(2048), + command: z.string().min(1, 'access.form.ssh.command.not.empty').max(2048, t('zod.rule.string.max', { max: 2048 })), + certPath: z.string().min(0, 'access.form.ssh.cert.path.not.empty').max(2048, t('zod.rule.string.max', { max: 2048 })), + keyPath: z.string().min(0, 'access.form.ssh.key.path.not.empty').max(2048, t('zod.rule.string.max', { max: 2048 })), }); let config: LocalConfig = { @@ -54,7 +56,7 @@ const AccessLocalForm = ({ resolver: zodResolver(formSchema), defaultValues: { id: data?.id, - name: data?.name, + name: data?.name || '', configType: "local", certPath: config.certPath, keyPath: config.keyPath, @@ -123,9 +125,9 @@ const AccessLocalForm = ({ name="name" render={({ field }) => ( - 名称 + {t('name')} - + @@ -138,7 +140,7 @@ const AccessLocalForm = ({ name="id" render={({ field }) => ( - 配置类型 + {t('access.form.config.field')} @@ -153,7 +155,7 @@ const AccessLocalForm = ({ name="configType" render={({ field }) => ( - 配置类型 + {t('access.form.config.field')} @@ -168,9 +170,9 @@ const AccessLocalForm = ({ name="certPath" render={({ field }) => ( - 证书保存路径 + {t('access.form.ssh.cert.path')} - + @@ -183,9 +185,9 @@ const AccessLocalForm = ({ name="keyPath" render={({ field }) => ( - 私钥保存路径 + {t('access.form.ssh.key.path')} - + @@ -198,9 +200,9 @@ const AccessLocalForm = ({ name="command" render={({ field }) => ( - Command + {t('access.form.ssh.command')} -