diff --git a/ui/src/components/certimate/AccessAliyunForm.tsx b/ui/src/components/certimate/AccessAliyunForm.tsx index 0d6edd73..874c10f4 100644 --- a/ui/src/components/certimate/AccessAliyunForm.tsx +++ b/ui/src/components/certimate/AccessAliyunForm.tsx @@ -1,5 +1,6 @@ import { Input } from "@/components/ui/input"; import { useForm } from "react-hook-form"; +import { useTranslation } from "react-i18next"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -29,12 +30,13 @@ const AccessAliyunForm = ({ onAfterReq: () => void; }) => { const { addAccess, updateAccess } = 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, - accessKeyId: z.string().min(1).max(64), - accessSecretId: z.string().min(1).max(64), + accessKeyId: z.string().min(1, 'access.form.access.key.id.not.empty').max(64, t('zod.rule.string.max', { max: 64 })), + accessSecretId: z.string().min(1, 'access.form.access.key.secret.not.empty').max(64, t('zod.rule.string.max', { max: 64 })), }); let config: AliyunConfig = { @@ -47,7 +49,7 @@ const AccessAliyunForm = ({ resolver: zodResolver(formSchema), defaultValues: { id: data?.id, - name: data?.name, + name: data?.name || '', configType: "aliyun", accessKeyId: config.accessKeyId, accessSecretId: config.accessKeySecret, @@ -111,9 +113,9 @@ const AccessAliyunForm = ({ name="name" render={({ field }) => ( - 名称 + {t('name')} - + @@ -126,7 +128,7 @@ const AccessAliyunForm = ({ name="id" render={({ field }) => ( - 配置类型 + {t('access.form.config.field')} @@ -141,7 +143,7 @@ const AccessAliyunForm = ({ name="configType" render={({ field }) => ( - 配置类型 + {t('access.form.config.field')} @@ -156,9 +158,9 @@ const AccessAliyunForm = ({ name="accessKeyId" render={({ field }) => ( - AccessKeyId + {t('access.form.access.key.id')} - + @@ -171,9 +173,9 @@ const AccessAliyunForm = ({ name="accessSecretId" render={({ field }) => ( - AccessKeySecret + {t('access.form.access.key.secret')} - + @@ -184,7 +186,7 @@ const AccessAliyunForm = ({
- +
diff --git a/ui/src/components/certimate/AccessCloudflareForm.tsx b/ui/src/components/certimate/AccessCloudflareForm.tsx index a28acc3c..adfdfc4a 100644 --- a/ui/src/components/certimate/AccessCloudflareForm.tsx +++ b/ui/src/components/certimate/AccessCloudflareForm.tsx @@ -1,5 +1,6 @@ import { Input } from "@/components/ui/input"; import { useForm } from "react-hook-form"; +import { useTranslation } from "react-i18next"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -28,11 +29,12 @@ const AccessCloudflareForm = ({ onAfterReq: () => void; }) => { const { addAccess, updateAccess } = 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, - dnsApiToken: z.string().min(1).max(64), + dnsApiToken: z.string().min(1, 'access.form.cloud.dns.api.token.not.empty').max(64, t('zod.rule.string.max', { max: 64 })), }); let config: CloudflareConfig = { @@ -44,7 +46,7 @@ const AccessCloudflareForm = ({ resolver: zodResolver(formSchema), defaultValues: { id: data?.id, - name: data?.name, + name: data?.name || '', configType: "cloudflare", dnsApiToken: config.dnsApiToken, }, @@ -106,9 +108,9 @@ const AccessCloudflareForm = ({ name="name" render={({ field }) => ( - 名称 + {t('name')} - + @@ -121,7 +123,7 @@ const AccessCloudflareForm = ({ name="id" render={({ field }) => ( - 配置类型 + {t('access.form.config.field')} @@ -136,7 +138,7 @@ const AccessCloudflareForm = ({ name="configType" render={({ field }) => ( - 配置类型 + {t('access.form.config.field')} @@ -151,9 +153,9 @@ const AccessCloudflareForm = ({ name="dnsApiToken" render={({ field }) => ( - CLOUD_DNS_API_TOKEN + {t('access.form.cloud.dns.api.token')} - + @@ -162,7 +164,7 @@ const AccessCloudflareForm = ({ />
- +
diff --git a/ui/src/components/certimate/AccessEdit.tsx b/ui/src/components/certimate/AccessEdit.tsx index f21b079f..fca6207b 100644 --- a/ui/src/components/certimate/AccessEdit.tsx +++ b/ui/src/components/certimate/AccessEdit.tsx @@ -8,6 +8,7 @@ import { import { ScrollArea } from "@/components/ui/scroll-area"; import { useState } from "react"; +import { useTranslation } from "react-i18next"; import AccessTencentForm from "./AccessTencentForm"; @@ -46,6 +47,7 @@ export function AccessEdit({ className, }: TargetConfigEditProps) { const [open, setOpen] = useState(false); + const { t } = useTranslation(); const typeKeys = Array.from(accessTypeMap.keys()); @@ -146,25 +148,24 @@ export function AccessEdit({ - {op == "add" ? "添加" : "编辑"}授权 + {op == "add" ? t('access.add') : t('access.edit')}
- + + @@ -130,7 +132,7 @@ const AccessGodaddyFrom = ({ name="id" render={({ field }) => ( - 配置类型 + {t('access.form.config.field')} @@ -145,7 +147,7 @@ const AccessGodaddyFrom = ({ name="configType" render={({ field }) => ( - 配置类型 + {t('access.form.config.field')} @@ -160,9 +162,9 @@ const AccessGodaddyFrom = ({ name="apiKey" render={({ field }) => ( - GODADDY_API_KEY + {t('access.form.go.daddy.api.key')} - + @@ -175,9 +177,9 @@ const AccessGodaddyFrom = ({ name="apiSecret" render={({ field }) => ( - GODADDY_API_SECRET + {t('access.form.go.daddy.api.secret')} - + @@ -186,7 +188,7 @@ const AccessGodaddyFrom = ({ />
- +
diff --git a/ui/src/components/certimate/AccessGroupEdit.tsx b/ui/src/components/certimate/AccessGroupEdit.tsx index 022746ab..47ff1a00 100644 --- a/ui/src/components/certimate/AccessGroupEdit.tsx +++ b/ui/src/components/certimate/AccessGroupEdit.tsx @@ -25,6 +25,7 @@ import { update } from "@/repository/access_group"; import { ClientResponseError } from "pocketbase"; import { PbErrorData } from "@/domain/base"; import { useState } from "react"; +import { useTranslation } from "react-i18next"; type AccessGroupEditProps = { className?: string; @@ -35,9 +36,10 @@ const AccessGroupEdit = ({ className, trigger }: AccessGroupEditProps) => { const { reloadAccessGroups } = useConfig(); const [open, setOpen] = useState(false); + const { t } = useTranslation(); const formSchema = z.object({ - name: z.string().min(1).max(64), + name: z.string().min(1, 'access.group.name.not.empty').max(64, t('zod.rule.string.max', { max: 64 })), }); const form = useForm>({ @@ -78,14 +80,13 @@ const AccessGroupEdit = ({ className, trigger }: AccessGroupEditProps) => { - 添加分组 + {t('access.group.add')}
{ - console.log(e); e.stopPropagation(); form.handleSubmit(onSubmit)(e); }} @@ -96,9 +97,9 @@ const AccessGroupEdit = ({ className, trigger }: AccessGroupEditProps) => { name="name" render={({ field }) => ( - 组名 + {t('access.group.name')} - + @@ -107,7 +108,7 @@ const AccessGroupEdit = ({ className, trigger }: AccessGroupEditProps) => { />
- +
diff --git a/ui/src/components/certimate/AccessGroupList.tsx b/ui/src/components/certimate/AccessGroupList.tsx index e0fe0395..04a0ec16 100644 --- a/ui/src/components/certimate/AccessGroupList.tsx +++ b/ui/src/components/certimate/AccessGroupList.tsx @@ -29,6 +29,7 @@ import { Group } from "lucide-react"; import { useToast } from "@/components/ui/use-toast"; import { useNavigate } from "react-router-dom"; +import { useTranslation } from "react-i18next"; const AccessGroupList = () => { const { @@ -39,8 +40,7 @@ const AccessGroupList = () => { const { toast } = useToast(); const navigate = useNavigate(); - - + const { t } = useTranslation(); const handleRemoveClick = async (id: string) => { try { @@ -48,7 +48,7 @@ const AccessGroupList = () => { reloadAccessGroups(); } catch (e) { toast({ - title: "删除失败", + title: t('delete.failed'), description: getErrMessage(e), variant: "destructive", }); @@ -69,10 +69,10 @@ const AccessGroupList = () => {
- 请添加域名开始部署证书吧。 + {t('access.group.domain.empty')}
新增授权组} + trigger={} className="mt-3" />
@@ -86,9 +86,7 @@ const AccessGroupList = () => { {accessGroup.name} - 共有 - {accessGroup.expand ? accessGroup.expand.access.length : 0} - 个部署授权配置 + {t('access.group.total', { total: accessGroup.expand ? accessGroup.expand.access.length : 0 })} @@ -123,7 +121,7 @@ const AccessGroupList = () => {
- 暂无部署授权配置,请添加后开始使用吧 + {t('access.group.empty')}
@@ -151,7 +149,7 @@ const AccessGroupList = () => { ); }} > - 所有授权 + {t('access.all')} @@ -159,14 +157,14 @@ const AccessGroupList = () => {
@@ -175,21 +173,21 @@ const AccessGroupList = () => { - 删除组 + {t('access.group.delete')} - 确定要删除部署授权组吗? + {t('access.group.delete.confirm')} - 取消 + {t('cancel')} { @@ -198,7 +196,7 @@ const AccessGroupList = () => { ); }} > - 确认 + {t('confirm')} diff --git a/ui/src/components/certimate/AccessNamesiloForm.tsx b/ui/src/components/certimate/AccessNamesiloForm.tsx index ac2abe13..d70d57b4 100644 --- a/ui/src/components/certimate/AccessNamesiloForm.tsx +++ b/ui/src/components/certimate/AccessNamesiloForm.tsx @@ -1,5 +1,6 @@ import { Input } from "@/components/ui/input"; import { useForm } from "react-hook-form"; +import { useTranslation } from "react-i18next"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -28,11 +29,12 @@ const AccessNamesiloForm = ({ onAfterReq: () => void; }) => { const { addAccess, updateAccess } = 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, - apiKey: z.string().min(1).max(64), + apiKey: z.string().min(1, 'access.form.namesilo.api.key.not.empty').max(64, t('zod.rule.string.max', { max: 64 })), }); let config: NamesiloConfig = { @@ -44,14 +46,13 @@ const AccessNamesiloForm = ({ resolver: zodResolver(formSchema), defaultValues: { id: data?.id, - name: data?.name, + name: data?.name || '', configType: "namesilo", apiKey: config.apiKey, }, }); const onSubmit = async (data: z.infer) => { - console.log(data); const req: Access = { id: data.id as string, name: data.name, @@ -106,9 +107,9 @@ const AccessNamesiloForm = ({ name="name" render={({ field }) => ( - 名称 + {t('name')} - + @@ -121,7 +122,7 @@ const AccessNamesiloForm = ({ name="id" render={({ field }) => ( - 配置类型 + {t('access.form.config.field')} @@ -136,7 +137,7 @@ const AccessNamesiloForm = ({ name="configType" render={({ field }) => ( - 配置类型 + {t('access.form.config.field')} @@ -151,9 +152,9 @@ const AccessNamesiloForm = ({ name="apiKey" render={({ field }) => ( - NAMESILO_API_KEY + {t('access.form.namesilo.api.key')} - + @@ -162,7 +163,7 @@ const AccessNamesiloForm = ({ />
- +
diff --git a/ui/src/components/certimate/AccessQiniuForm.tsx b/ui/src/components/certimate/AccessQiniuForm.tsx index 7b58f07d..125f7ae9 100644 --- a/ui/src/components/certimate/AccessQiniuForm.tsx +++ b/ui/src/components/certimate/AccessQiniuForm.tsx @@ -1,5 +1,6 @@ import { Input } from "@/components/ui/input"; import { useForm } from "react-hook-form"; +import { useTranslation } from "react-i18next"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -29,12 +30,13 @@ const AccessQiniuForm = ({ onAfterReq: () => void; }) => { const { addAccess, updateAccess } = 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, - accessKey: z.string().min(1).max(64), - secretKey: z.string().min(1).max(64), + accessKey: z.string().min(1, 'access.form.access.key.not.empty').max(64), + secretKey: z.string().min(1, 'access.form.secret.key.not.empty').max(64), }); let config: QiniuConfig = { @@ -47,7 +49,7 @@ const AccessQiniuForm = ({ resolver: zodResolver(formSchema), defaultValues: { id: data?.id, - name: data?.name, + name: data?.name || '', configType: "qiniu", accessKey: config.accessKey, secretKey: config.secretKey, @@ -111,9 +113,9 @@ const AccessQiniuForm = ({ name="name" render={({ field }) => ( - 名称 + {t('name')} - + @@ -126,7 +128,7 @@ const AccessQiniuForm = ({ name="id" render={({ field }) => ( - 配置类型 + {t('access.form.config.field')} @@ -141,7 +143,7 @@ const AccessQiniuForm = ({ name="configType" render={({ field }) => ( - 配置类型 + {t('access.form.config.field')} @@ -156,9 +158,9 @@ const AccessQiniuForm = ({ name="accessKey" render={({ field }) => ( - AccessKey + {t('access.form.access.key')} - + @@ -171,9 +173,9 @@ const AccessQiniuForm = ({ name="secretKey" render={({ field }) => ( - SecretKey + {t('access.form.secret.key')} - + @@ -184,7 +186,7 @@ const AccessQiniuForm = ({
- +
diff --git a/ui/src/components/certimate/AccessSSHForm.tsx b/ui/src/components/certimate/AccessSSHForm.tsx index b7af5b4e..5e4696f3 100644 --- a/ui/src/components/certimate/AccessSSHForm.tsx +++ b/ui/src/components/certimate/AccessSSHForm.tsx @@ -24,6 +24,7 @@ import { ClientResponseError } from "pocketbase"; import { PbErrorData } from "@/domain/base"; import { readFileContent } from "@/lib/file"; import { useRef, useState } from "react"; +import { useTranslation } from "react-i18next"; import { Select, SelectContent, @@ -53,6 +54,7 @@ const AccessSSHForm = ({ const fileInputRef = useRef(null); const [fileName, setFileName] = useState(""); + const { t } = useTranslation(); const originGroup = data ? (data.group ? data.group : "") : ""; @@ -62,25 +64,25 @@ const AccessSSHForm = ({ 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, host: z.string().refine( (str) => { return ipReg.test(str) || domainReg.test(str); }, { - message: "请输入正确的域名或IP", + message: "zod.rule.ssh.host", } ), group: z.string().optional(), - port: z.string().min(1).max(5), - username: z.string().min(1).max(64), - password: z.string().min(0).max(64), - key: z.string().min(0).max(20480), + port: z.string().min(1, 'access.form.ssh.port.not.empty').max(5, t('zod.rule.string.max', { max: 5 })), + username: z.string().min(1, 'username.not.empty').max(64, t('zod.rule.string.max', { max: 64 })), + password: z.string().min(0, 'password.not.empty').max(64, t('zod.rule.string.max', { max: 64 })), + key: z.string().min(0, 'access.form.ssh.key.not.empty').max(20480, t('zod.rule.string.max', { max: 20480 })), keyFile: z.any().optional(), - 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: SSHConfig = { @@ -100,7 +102,7 @@ const AccessSSHForm = ({ resolver: zodResolver(formSchema), defaultValues: { id: data?.id, - name: data?.name, + name: data?.name || '', configType: "ssh", group: data?.group, host: config.host, @@ -219,9 +221,9 @@ const AccessSSHForm = ({ name="name" render={({ field }) => ( - 名称 + {t('name')} - + @@ -235,12 +237,12 @@ const AccessSSHForm = ({ render={({ field }) => ( -
授权配置组(用于将一个域名证书部署到多个 ssh 主机)
+
{t('access.form.ssh.group.label')}
- 新增 + {t('add')} } /> @@ -255,7 +257,7 @@ const AccessSSHForm = ({ }} > - + @@ -295,7 +297,7 @@ const AccessSSHForm = ({ name="id" render={({ field }) => ( - 配置类型 + {t('access.form.config.field')} @@ -310,7 +312,7 @@ const AccessSSHForm = ({ name="configType" render={({ field }) => ( - 配置类型 + {t('access.form.config.field')} @@ -325,9 +327,9 @@ const AccessSSHForm = ({ name="host" render={({ field }) => ( - 服务器HOST + {t('access.form.ssh.host')} - + @@ -340,10 +342,10 @@ const AccessSSHForm = ({ name="port" render={({ field }) => ( - SSH端口 + {t('access.form.ssh.port')} @@ -360,9 +362,9 @@ const AccessSSHForm = ({ name="username" render={({ field }) => ( - 用户名 + {t('username')} - + @@ -375,10 +377,10 @@ const AccessSSHForm = ({ name="password" render={({ field }) => ( - 密码 + {t('password')} @@ -394,9 +396,9 @@ const AccessSSHForm = ({ name="key" render={({ field }) => (