From 3febc866600cad31ab19a2eeaea4a7b65480239e Mon Sep 17 00:00:00 2001 From: Exergenion Date: Tue, 21 Apr 2026 12:09:18 +0200 Subject: [PATCH] fix: replace hardcoded Chinese strings in settings with i18n keys Four settings sections (Interface, About, Output, Embedding) had hardcoded Chinese strings instead of i18n translation keys, causing the Settings panel to always display in Chinese regardless of the selected UI language. - Add missing translation keys to en.json and zh.json for all four sections (interfaceHeading, outputHeading, embeddingHeading, aboutHeading, and all associated labels/hints) - Wire useTranslation() into InterfaceSection, AboutSection, OutputSection, and EmbeddingSection --- .../settings/sections/about-section.tsx | 10 +++++---- .../settings/sections/embedding-section.tsx | 14 +++++++----- .../settings/sections/interface-section.tsx | 11 ++++++---- .../settings/sections/output-section.tsx | 21 +++++++++++------- src/i18n/en.json | 22 ++++++++++++++++++- src/i18n/zh.json | 22 ++++++++++++++++++- 6 files changed, 76 insertions(+), 24 deletions(-) diff --git a/src/components/settings/sections/about-section.tsx b/src/components/settings/sections/about-section.tsx index e30005e5..8c2a96a6 100644 --- a/src/components/settings/sections/about-section.tsx +++ b/src/components/settings/sections/about-section.tsx @@ -1,7 +1,9 @@ import { useEffect, useState } from "react" +import { useTranslation } from "react-i18next" import { clipServerStatus } from "@/commands/fs" export function AboutSection() { + const { t } = useTranslation() const [clipStatus, setClipStatus] = useState("...") useEffect(() => { @@ -19,16 +21,16 @@ export function AboutSection() { }, []) const rows: Array<{ label: string; value: string; mono?: boolean }> = [ - { label: "版本", value: `v${__APP_VERSION__}`, mono: true }, - { label: "Clip Server", value: `${clipStatus} @ 127.0.0.1:19827`, mono: true }, + { label: t("settings.aboutVersion"), value: `v${__APP_VERSION__}`, mono: true }, + { label: t("settings.aboutClipServer"), value: `${clipStatus} @ 127.0.0.1:19827`, mono: true }, ] return (
-

关于

+

{t("settings.aboutHeading")}

- 构建信息和运行时状态。 + {t("settings.aboutDescription")}

diff --git a/src/components/settings/sections/embedding-section.tsx b/src/components/settings/sections/embedding-section.tsx index a8bfa279..2f131f85 100644 --- a/src/components/settings/sections/embedding-section.tsx +++ b/src/components/settings/sections/embedding-section.tsx @@ -1,3 +1,4 @@ +import { useTranslation } from "react-i18next" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import type { SettingsDraft, DraftSetter } from "../settings-types" @@ -8,21 +9,22 @@ interface Props { } export function EmbeddingSection({ draft, setDraft }: Props) { + const { t } = useTranslation() + return (
-

向量嵌入

+

{t("settings.embeddingHeading")}

- 启用语义搜索。对任何 OpenAI 兼容的 /v1/embeddings endpoint 工作。 - 本地模型(如 LM Studio、Ollama embedding)不需要 API Key。 + {t("settings.embeddingDescription")}

-
启用向量搜索
+
{t("settings.embeddingEnable")}
- 关掉后搜索只走 token 匹配。 + {t("settings.embeddingEnableHint")}
diff --git a/src/components/settings/sections/interface-section.tsx b/src/components/settings/sections/interface-section.tsx index 954f287c..a8bbbff8 100644 --- a/src/components/settings/sections/interface-section.tsx +++ b/src/components/settings/sections/interface-section.tsx @@ -1,3 +1,4 @@ +import { useTranslation } from "react-i18next" import { Label } from "@/components/ui/label" import type { SettingsDraft, DraftSetter } from "../settings-types" @@ -12,17 +13,19 @@ const UI_LANGUAGES = [ ] export function InterfaceSection({ draft, setDraft }: Props) { + const { t } = useTranslation() + return (
-

界面

+

{t("settings.interfaceHeading")}

- 应用 UI 的显示语言。切换后立即生效并持久化。 + {t("settings.interfaceDescription")}

- +
{UI_LANGUAGES.map((l) => { const active = draft.uiLanguage === l.value @@ -43,7 +46,7 @@ export function InterfaceSection({ draft, setDraft }: Props) { })}

- 只影响按钮、标签这些 UI 文案,不影响 AI 输出语言(那个在"输出偏好"里单独设置)。 + {t("settings.uiLanguageHint")}

diff --git a/src/components/settings/sections/output-section.tsx b/src/components/settings/sections/output-section.tsx index db80a03d..14a5aadb 100644 --- a/src/components/settings/sections/output-section.tsx +++ b/src/components/settings/sections/output-section.tsx @@ -1,3 +1,4 @@ +import { useTranslation } from "react-i18next" import { Label } from "@/components/ui/label" import type { SettingsDraft, DraftSetter } from "../settings-types" @@ -33,20 +34,21 @@ const LANGUAGE_OPTIONS = [ const HISTORY_OPTIONS = [2, 4, 6, 8, 10, 20] export function OutputSection({ draft, setDraft }: Props) { + const { t } = useTranslation() + return (
-

输出偏好

+

{t("settings.outputHeading")}

- 控制 AI 生成内容的语言和对话上下文长度。 + {t("settings.outputDescription")}

- +

- 强制 AI 生成内容(chat 回复、wiki 页面、research 结果、lint 报告)使用指定语言。 - 选 "Auto" 让 AI 跟随用户输入或源文档的语言。 + {t("settings.outputLanguageHint")}