feat(i18n): enhance language switching and UI consistency across themes and components

This commit is contained in:
HouYunFei
2026-08-05 14:51:56 +08:00
parent ec82958f7c
commit 8e5073ccc2
11 changed files with 100 additions and 44 deletions
@@ -1,11 +1,13 @@
import type { CSSProperties } from "react";
import { BookOpen, Keyboard, Puzzle, Settings2 } from "lucide-react";
import { BookOpen, Globe2, Keyboard, Puzzle, Settings2 } from "lucide-react";
import { Dropdown } from "antd";
import { useTranslation } from "react-i18next";
import { AnimatedThemeToggler } from "@/components/ui/animated-theme-toggler";
import { GitHubLink } from "@/components/layout/github-link";
import { VersionReleaseModal } from "@/components/layout/version-release-modal";
import { DOCS_URL } from "@/constant/env";
import { changeAppLocale, type AppLocale } from "@/i18n";
import { cn } from "@/lib/utils";
import { canvasThemes } from "@/lib/canvas-theme";
import { useConfigStore } from "@/stores/use-config-store";
@@ -19,7 +21,7 @@ type UserStatusActionsProps = {
};
export function UserStatusActions({ showConfig = true, variant = "default", onOpenShortcuts, onOpenPlugins }: UserStatusActionsProps) {
const { t } = useTranslation();
const { i18n, t } = useTranslation();
const theme = useThemeStore((state) => state.theme);
const setTheme = useThemeStore((state) => state.setTheme);
const openConfigDialog = useConfigStore((state) => state.openConfigDialog);
@@ -45,6 +47,22 @@ export function UserStatusActions({ showConfig = true, variant = "default", onOp
<Settings2 className="size-4" />
</button>
) : null}
<Dropdown
trigger={["click"]}
placement="bottomRight"
menu={{
selectedKeys: [i18n.resolvedLanguage],
items: [
{ key: "zh-CN", label: t("locale.zhCN") },
{ key: "en-US", label: t("locale.enUS") },
],
onClick: ({ key }) => void changeAppLocale(key as AppLocale),
}}
>
<button type="button" className={naturalIconClass} style={iconStyle} aria-label={t("topNav.language")} title={t("topNav.language")}>
<Globe2 className="size-4" />
</button>
</Dropdown>
<AnimatedThemeToggler theme={theme} onThemeChange={setTheme} className={naturalIconClass} style={iconStyle} aria-label={t(theme === "dark" ? "topNav.lightTheme" : "topNav.darkTheme")} title={t(theme === "dark" ? "topNav.lightTheme" : "topNav.darkTheme")} />
<VersionReleaseModal style={versionStyle} />
<GitHubLink className={cn("bg-transparent hover:bg-transparent dark:hover:bg-transparent", gitHubClassName)} style={gitHubStyle} />