Skip to content

Commit

Permalink
Merge branch 'l123wx-i18n'
Browse files Browse the repository at this point in the history
  • Loading branch information
usual2970 committed Sep 27, 2024
2 parents 9797a08 + 3c56a53 commit 6b85b4a
Show file tree
Hide file tree
Showing 48 changed files with 1,531 additions and 805 deletions.
313 changes: 0 additions & 313 deletions ui/dist/assets/index-CQVPrK_Y.js

This file was deleted.

1 change: 0 additions & 1 deletion ui/dist/assets/index-Djc_JtNf.css

This file was deleted.

1 change: 1 addition & 0 deletions ui/dist/assets/index-I--T0qY3.css

Large diffs are not rendered by default.

322 changes: 322 additions & 0 deletions ui/dist/assets/index-TzNEc_kS.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ui/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Certimate - Your Trusted SSL Automation Partner</title>
<script type="module" crossorigin src="/assets/index-CQVPrK_Y.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-Djc_JtNf.css">
<script type="module" crossorigin src="/assets/index-TzNEc_kS.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-I--T0qY3.css">
</head>
<body class="bg-background">
<div id="root"></div>
Expand Down
141 changes: 141 additions & 0 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
"tailwind-merge": "^2.4.0",
"tailwindcss-animate": "^1.0.7",
"vaul": "^0.9.1",
"zod": "^3.23.8"
"zod": "^3.23.8",
"i18next": "^23.15.1",
"i18next-browser-languagedetector": "^8.0.0",
"i18next-http-backend": "^2.6.1",
"react-i18next": "^15.0.2"
},
"devDependencies": {
"@types/node": "^22.0.0",
Expand Down
33 changes: 33 additions & 0 deletions ui/src/components/LocaleToggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Languages } from "lucide-react";

import { useTranslation } from "react-i18next";

import { Button } from "@/components/ui/button";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";

export default function LocaleToggle() {
const { i18n } = useTranslation()

return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline" size="icon">
<Languages className="h-[1.2rem] w-[1.2rem] dark:text-white" />
<span className="sr-only">Toggle theme</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
{Object.keys(i18n.store.data).map(key => (
<DropdownMenuItem onClick={() => i18n.changeLanguage(key)}>
{i18n.store.data[key].name as string}
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
);
}
9 changes: 6 additions & 3 deletions ui/src/components/ThemeToggle.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Moon, Sun } from "lucide-react";
import { useTranslation } from 'react-i18next'

import { Button } from "@/components/ui/button";
import {
Expand All @@ -11,6 +12,8 @@ import { useTheme } from "./ThemeProvider";

export function ThemeToggle() {
const { setTheme } = useTheme();
const { t } = useTranslation();


return (
<DropdownMenu>
Expand All @@ -23,13 +26,13 @@ export function ThemeToggle() {
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={() => setTheme("light")}>
浅色
{t('theme.light')}
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTheme("dark")}>
暗黑
{t('theme.dark')}
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTheme("system")}>
系统
{t('theme.system')}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
Expand Down
28 changes: 15 additions & 13 deletions ui/src/components/certimate/AccessAliyunForm.tsx
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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 = {
Expand All @@ -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,
Expand Down Expand Up @@ -111,9 +113,9 @@ const AccessAliyunForm = ({
name="name"
render={({ field }) => (
<FormItem>
<FormLabel>名称</FormLabel>
<FormLabel>{t('name')}</FormLabel>
<FormControl>
<Input placeholder="请输入授权名称" {...field} />
<Input placeholder={t('access.form.name.not.empty')} {...field} />
</FormControl>

<FormMessage />
Expand All @@ -126,7 +128,7 @@ const AccessAliyunForm = ({
name="id"
render={({ field }) => (
<FormItem className="hidden">
<FormLabel>配置类型</FormLabel>
<FormLabel>{t('access.form.config.field')}</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
Expand All @@ -141,7 +143,7 @@ const AccessAliyunForm = ({
name="configType"
render={({ field }) => (
<FormItem className="hidden">
<FormLabel>配置类型</FormLabel>
<FormLabel>{t('access.form.config.field')}</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
Expand All @@ -156,9 +158,9 @@ const AccessAliyunForm = ({
name="accessKeyId"
render={({ field }) => (
<FormItem>
<FormLabel>AccessKeyId</FormLabel>
<FormLabel>{t('access.form.access.key.id')}</FormLabel>
<FormControl>
<Input placeholder="请输入AccessKeyId" {...field} />
<Input placeholder={t('access.form.access.key.id.not.empty')} {...field} />
</FormControl>

<FormMessage />
Expand All @@ -171,9 +173,9 @@ const AccessAliyunForm = ({
name="accessSecretId"
render={({ field }) => (
<FormItem>
<FormLabel>AccessKeySecret</FormLabel>
<FormLabel>{t('access.form.access.key.secret')}</FormLabel>
<FormControl>
<Input placeholder="请输入AccessKeySecret" {...field} />
<Input placeholder={t('access.form.access.key.secret.not.empty')} {...field} />
</FormControl>

<FormMessage />
Expand All @@ -184,7 +186,7 @@ const AccessAliyunForm = ({
<FormMessage />

<div className="flex justify-end">
<Button type="submit">保存</Button>
<Button type="submit">{t('save')}</Button>
</div>
</form>
</Form>
Expand Down
Loading

0 comments on commit 6b85b4a

Please sign in to comment.