Files
cc-switch/src/components/settings/ThemeSettings.tsx
Jason bae6a1cf55 i18n: complete internationalization for settings panel
- Add missing translation keys for all hint texts and descriptions
- Remove all hardcoded defaultValue parameters from components
- Add translations for window behavior, directory settings, and theme settings
- Add translations for provider-related UI elements
- Improve consistency across Chinese and English translations

Translation additions:
- common.toggleTheme
- settings.windowBehaviorHint, claudeConfigDirDescription, codexConfigDirDescription
- provider.* (12 new keys)
- providerForm.* (15 new keys)
- providerPreset.* (4 new keys)

Modified files: 10
Lines changed: +132 -74
2025-10-19 11:01:53 +08:00

77 lines
1.9 KiB
TypeScript

import { Monitor, Moon, Sun } from "lucide-react";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
import { useTranslation } from "react-i18next";
import { useTheme } from "@/components/theme-provider";
export function ThemeSettings() {
const { t } = useTranslation();
const { theme, setTheme } = useTheme();
return (
<section className="space-y-2">
<header className="space-y-1">
<h3 className="text-sm font-medium">{t("settings.theme")}</h3>
<p className="text-xs text-muted-foreground">
{t("settings.themeHint")}
</p>
</header>
<div className="inline-flex gap-1 rounded-md border border-border bg-background p-1">
<ThemeButton
active={theme === "light"}
onClick={() => setTheme("light")}
icon={Sun}
>
{t("settings.themeLight")}
</ThemeButton>
<ThemeButton
active={theme === "dark"}
onClick={() => setTheme("dark")}
icon={Moon}
>
{t("settings.themeDark")}
</ThemeButton>
<ThemeButton
active={theme === "system"}
onClick={() => setTheme("system")}
icon={Monitor}
>
{t("settings.themeSystem")}
</ThemeButton>
</div>
</section>
);
}
interface ThemeButtonProps {
active: boolean;
onClick: () => void;
icon: React.ComponentType<{ className?: string }>;
children: React.ReactNode;
}
function ThemeButton({
active,
onClick,
icon: Icon,
children,
}: ThemeButtonProps) {
return (
<Button
type="button"
onClick={onClick}
size="sm"
variant={active ? "default" : "ghost"}
className={cn(
"min-w-[96px] gap-1.5",
active
? "shadow-sm"
: "text-muted-foreground hover:text-foreground hover:bg-muted",
)}
>
<Icon className="h-3.5 w-3.5" />
{children}
</Button>
);
}