refactor: support i18n

This commit is contained in:
mlogclub
2026-05-25 12:06:15 +08:00
parent 309ac1fe9e
commit 988f55c80d
179 changed files with 10968 additions and 3763 deletions
@@ -5,6 +5,7 @@ import { CopyIcon } from "lucide-react"
import { toast } from "sonner"
import { Button } from "@/components/ui/button"
import { useI18n } from "@/i18n/provider"
import {
Dialog,
DialogContent,
@@ -27,6 +28,7 @@ export function InitialPasswordDialog({
password,
onOpenChange,
}: InitialPasswordDialogProps) {
const t = useI18n()
const [copying, setCopying] = useState(false)
async function handleCopy() {
@@ -37,9 +39,9 @@ export function InitialPasswordDialog({
setCopying(true)
try {
await navigator.clipboard.writeText(password)
toast.success("密码已复制")
toast.success(t("user.copied"))
} catch {
toast.error("复制失败,请手动复制")
toast.error(t("user.copyFailed"))
} finally {
setCopying(false)
}
@@ -49,13 +51,13 @@ export function InitialPasswordDialog({
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent>
<DialogHeader>
<DialogTitle></DialogTitle>
<DialogTitle>{t("user.createdTitle")}</DialogTitle>
<DialogDescription>
{username || "-"}
{t("user.initialPasswordDescription", { username: username || "-" })}
</DialogDescription>
</DialogHeader>
<div className="rounded-xl border bg-muted/40 p-4">
<div className="text-xs text-muted-foreground"></div>
<div className="text-xs text-muted-foreground">{t("user.initialPassword")}</div>
<div className="mt-2 break-all font-mono text-base">{password}</div>
</div>
<DialogFooter>
@@ -66,10 +68,10 @@ export function InitialPasswordDialog({
disabled={copying || !password}
>
<CopyIcon />
{copying ? "复制中..." : "复制密码"}
{copying ? t("user.copying") : t("user.copyPassword")}
</Button>
<Button type="button" onClick={() => onOpenChange(false)}>
{t("user.close")}
</Button>
</DialogFooter>
</DialogContent>