From abd4f49c4d4e18db205a2948fdca0889b937fe78 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 11 Jun 2026 00:26:50 +0800
Subject: [PATCH] feat(ui): add chinese localization
---
packages/ui/src/components/bottom-bar.tsx | 20 +-
packages/ui/src/components/config-editor.tsx | 12 +-
.../src/components/instance-editor-modal.tsx | 109 ++++----
packages/ui/src/components/login-modal.tsx | 39 ++-
packages/ui/src/components/sidebar.tsx | 16 +-
packages/ui/src/lib/i18n.tsx | 98 +++++++
packages/ui/src/lib/locales/en.ts | 198 ++++++++++++++
packages/ui/src/lib/locales/zh.ts | 194 ++++++++++++++
packages/ui/src/main.tsx | 7 +-
packages/ui/src/models/auth.ts | 27 +-
packages/ui/src/models/instance.ts | 24 +-
packages/ui/src/models/settings.ts | 3 +-
packages/ui/src/pages/home.tsx | 6 +-
packages/ui/src/pages/instances/create.tsx | 117 +++++----
packages/ui/src/pages/instances/index.tsx | 47 ++--
packages/ui/src/pages/settings.tsx | 243 +++++++++++-------
16 files changed, 876 insertions(+), 284 deletions(-)
create mode 100644 packages/ui/src/lib/i18n.tsx
create mode 100644 packages/ui/src/lib/locales/en.ts
create mode 100644 packages/ui/src/lib/locales/zh.ts
diff --git a/packages/ui/src/components/bottom-bar.tsx b/packages/ui/src/components/bottom-bar.tsx
index f73ace46..ad5beb09 100644
--- a/packages/ui/src/components/bottom-bar.tsx
+++ b/packages/ui/src/components/bottom-bar.tsx
@@ -1,6 +1,7 @@
import { Play, User, XIcon } from "lucide-react";
import { useCallback, useState } from "react";
import { toast } from "sonner";
+import { useI18n } from "@/lib/i18n";
import { cn } from "@/lib/utils";
import { useAuthStore } from "@/models/auth";
import { useGameStore } from "@/models/game";
@@ -18,6 +19,7 @@ import {
import { Spinner } from "./ui/spinner";
export function BottomBar() {
+ const { t } = useI18n();
const account = useAuthStore((state) => state.account);
const { instances, activeInstance, setActiveInstance } = useInstanceStore();
@@ -48,15 +50,15 @@ export function BottomBar() {
await setActiveInstance(nextInstance);
} catch (error) {
console.error("Failed to activate instance:", error);
- toast.error(`Failed to activate instance: ${String(error)}`);
+ toast.error(t("bottom.activateFailed", { error: String(error) }));
}
},
- [activeInstance?.id, instances, setActiveInstance],
+ [activeInstance?.id, instances, setActiveInstance, t],
);
const handleStartGame = async () => {
if (!activeInstance) {
- toast.info("Please select an instance first!");
+ toast.info(t("bottom.selectInstanceFirst"));
return;
}
@@ -77,7 +79,7 @@ export function BottomBar() {
size="lg"
onClick={() => setShowLoginModal(true)}
>
-