From a852ac2176230ea8e3faeed5d6443eb41ffa1833 Mon Sep 17 00:00:00 2001 From: HybridTalentComputing <1316645276@qq.com> Date: Tue, 23 Dec 2025 22:19:34 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=B1=89=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/storage/utils/state-helpers.ts | 2 +- .../components/layout/WelcomeSection.tsx | 60 ++++++++++++++++++- .../components/common/CliInstallBanner.tsx | 32 +++++----- .../src/components/common/InfoBanner.tsx | 8 ++- .../src/context/ExtensionStateContext.tsx | 2 +- webview-ui/src/locales/en/common.json | 47 +++++++++++++++ webview-ui/src/locales/zh-CN/common.json | 47 +++++++++++++++ 7 files changed, 175 insertions(+), 23 deletions(-) diff --git a/src/core/storage/utils/state-helpers.ts b/src/core/storage/utils/state-helpers.ts index 76f3eadc..fbcbad3e 100644 --- a/src/core/storage/utils/state-helpers.ts +++ b/src/core/storage/utils/state-helpers.ts @@ -663,7 +663,7 @@ export async function readGlobalStateFromDisk(context: ExtensionContext): Promis autoApprovalSettings: autoApprovalSettings || DEFAULT_AUTO_APPROVAL_SETTINGS, // default value can be 0 or empty string globalClineRulesToggles: globalClineRulesToggles || {}, browserSettings: { ...DEFAULT_BROWSER_SETTINGS, ...browserSettings }, // this will ensure that older versions of browserSettings (e.g. before remoteBrowserEnabled was added) are merged with the default values (false for remoteBrowserEnabled) - preferredLanguage: preferredLanguage || "English", + preferredLanguage: preferredLanguage || "Simplified Chinese - 简体中文", openaiReasoningEffort: (openaiReasoningEffort as OpenaiReasoningEffort) || "medium", mode: mode || "act", userInfo, diff --git a/webview-ui/src/components/chat/chat-view/components/layout/WelcomeSection.tsx b/webview-ui/src/components/chat/chat-view/components/layout/WelcomeSection.tsx index 6ab9e329..81c51cbf 100644 --- a/webview-ui/src/components/chat/chat-view/components/layout/WelcomeSection.tsx +++ b/webview-ui/src/components/chat/chat-view/components/layout/WelcomeSection.tsx @@ -1,6 +1,7 @@ import { BANNER_DATA, BannerAction, BannerActionType, BannerCardData } from "@shared/cline/banner" import { EmptyRequest, Int64Request } from "@shared/proto/index.cline" import React, { useCallback, useEffect, useMemo, useState } from "react" +import { useTranslation } from "react-i18next" import BannerCarousel from "@/components/common/BannerCarousel" import { CURRENT_CLI_BANNER_VERSION } from "@/components/common/CliInstallBanner" import { CURRENT_INFO_BANNER_VERSION } from "@/components/common/InfoBanner" @@ -35,6 +36,7 @@ export const WelcomeSection: React.FC = ({ const [hasShownWhatsNewModal, setHasShownWhatsNewModal] = useState(false) const [showWhatsNewModal, setShowWhatsNewModal] = useState(false) + const { t } = useTranslation() const { clineUser } = useClineAuth() const { openRouterModels, setShowChatModelSelector, navigateToSettings, subagentsEnabled } = useExtensionState() const { handleFieldsChange } = useApiConfigurationHandlers() @@ -79,7 +81,7 @@ export const WelcomeSection: React.FC = ({ */ const bannerConfig = useMemo((): BannerCardData[] => { // Filter banners based on version tracking and user status - return BANNER_DATA.filter((banner) => { + const filteredBanners = BANNER_DATA.filter((banner) => { if (isBannerDismissed(banner.id)) { return false } @@ -94,7 +96,61 @@ export const WelcomeSection: React.FC = ({ return true }) - }, [isBannerDismissed, clineUser]) + + // Apply translations to banner titles and descriptions + return filteredBanners.map((banner) => { + const translatedBanner = { ...banner } + + // Translate based on banner ID + switch (banner.id) { + case "info-banner-v1": + translatedBanner.title = t("banner.rightSidebar.title") + translatedBanner.description = t("banner.rightSidebar.description") + break + case "new-model-opus-4-5-cline-users": + translatedBanner.title = t("banner.opus45ClineUsers.title") + translatedBanner.description = t("banner.opus45ClineUsers.description") + if (translatedBanner.actions) { + translatedBanner.actions = translatedBanner.actions.map((action) => ({ + ...action, + title: action.title === "Try Now" ? t("banner.opus45ClineUsers.tryNow") : action.title, + })) + } + break + case "new-model-opus-4-5-non-cline-users": + translatedBanner.title = t("banner.opus45NonClineUsers.title") + translatedBanner.description = t("banner.opus45NonClineUsers.description") + if (translatedBanner.actions) { + translatedBanner.actions = translatedBanner.actions.map((action) => ({ + ...action, + title: action.title === "Get Started" ? t("banner.opus45NonClineUsers.getStarted") : action.title, + })) + } + break + case "cli-install-unix-v1": + translatedBanner.title = t("banner.cliInstallUnix.title") + translatedBanner.description = t("banner.cliInstallUnix.description") + if (translatedBanner.actions) { + translatedBanner.actions = translatedBanner.actions.map((action) => { + if (action.title === "Install") { + return { ...action, title: t("banner.cliInstallUnix.install") } + } + if (action.title === "Enable Subagents") { + return { ...action, title: t("banner.cliInstallUnix.enableSubagents") } + } + return action + }) + } + break + case "cli-info-windows-v1": + translatedBanner.title = t("banner.cliInfoWindows.title") + translatedBanner.description = t("banner.cliInfoWindows.description") + break + } + + return translatedBanner + }) + }, [isBannerDismissed, clineUser, t]) /** * Action handler - maps action types to actual implementations diff --git a/webview-ui/src/components/common/CliInstallBanner.tsx b/webview-ui/src/components/common/CliInstallBanner.tsx index aca07878..75116ffa 100644 --- a/webview-ui/src/components/common/CliInstallBanner.tsx +++ b/webview-ui/src/components/common/CliInstallBanner.tsx @@ -2,6 +2,7 @@ import { EmptyRequest, Int64Request } from "@shared/proto/index.cline" import { VSCodeButton } from "@vscode/webview-ui-toolkit/react" import { Terminal, XIcon } from "lucide-react" import { useCallback, useEffect, useState } from "react" +import { useTranslation } from "react-i18next" import { Button } from "@/components/ui/button" import { useExtensionState } from "@/context/ExtensionStateContext" import { StateServiceClient } from "@/services/grpc-client" @@ -11,6 +12,7 @@ import { getAsVar, VSC_INACTIVE_SELECTION_BACKGROUND } from "@/utils/vscStyles" export const CURRENT_CLI_BANNER_VERSION = 1 export const CliInstallBanner: React.FC = () => { + const { t } = useTranslation() const { navigateToSettings, subagentsEnabled } = useExtensionState() const [isCopied, setIsCopied] = useState(false) const [isClineCliInstalled, setIsClineCliInstalled] = useState(false) @@ -92,31 +94,29 @@ export const CliInstallBanner: React.FC = () => { }}>

- {isMacOSOrLinux() ? "Cline for CLI is here!" : "Cline CLI Information"} + {isMacOSOrLinux() ? t("banner.cliInstallBanner.titleUnix") : t("banner.cliInstallBanner.titleWindows")}

{isMacOSOrLinux() ? ( <> - Install to use Cline directly in your terminal and enable subagent capabilities. Cline can spawn{" "} - cline commands to handle focused tasks like exploring large codebases for information. This - keeps your main context window clean by running these operations in separate subprocesses.{" "} + {" "} - Learn more + {t("banner.cliInstallBanner.learnMore")} ) : ( <> - Cline CLI is available for macOS and Linux! Coming soon to other platforms.{" "} + {" "} - Learn more + {t("banner.cliInstallBanner.learnMore")} )} @@ -134,7 +134,7 @@ export const CliInstallBanner: React.FC = () => { appearance="icon" onClick={handleCopyCommand} style={{ marginLeft: "8px", flexShrink: 0 }} - title={isCopied ? "Copied!" : "Copy command"}> + title={isCopied ? t("banner.cliInstallBanner.copied") : t("banner.cliInstallBanner.copyCommand")}> @@ -148,10 +148,10 @@ export const CliInstallBanner: React.FC = () => { {isClineCliInstalled ? ( <> - Installed + {t("banner.cliInstallBanner.installed")} ) : ( - "Install" + t("banner.cliInstallBanner.install") )} { className="flex-1" disabled={subagentsEnabled} onClick={handleEnableSubagents} - title="Configure Subagents"> - Enable Subagents + title={t("banner.cliInstallBanner.configureSubagents")}> + {t("banner.cliInstallBanner.enableSubagents")} ) : ( @@ -173,18 +173,18 @@ export const CliInstallBanner: React.FC = () => { {isClineCliInstalled ? ( <> - Installed + {t("banner.cliInstallBanner.installed")} ) : ( - "Install CLI" + t("banner.cliInstallBanner.installCli") )} - Subagents (Windows coming soon) + title={t("banner.cliInstallBanner.subagentsWindowsTooltip")}> + {t("banner.cliInstallBanner.subagentsWindows")} )} diff --git a/webview-ui/src/components/common/InfoBanner.tsx b/webview-ui/src/components/common/InfoBanner.tsx index fc9b04f9..a3d2067c 100644 --- a/webview-ui/src/components/common/InfoBanner.tsx +++ b/webview-ui/src/components/common/InfoBanner.tsx @@ -1,11 +1,13 @@ import { XIcon } from "lucide-react" import { useCallback } from "react" +import { useTranslation } from "react-i18next" import { Button } from "@/components/ui/button" import { PlatformType } from "@/config/platform.config" import { usePlatform } from "@/context/PlatformContext" import { StateServiceClient } from "@/services/grpc-client" export const CURRENT_INFO_BANNER_VERSION = 1 export const InfoBanner: React.FC = () => { + const { t } = useTranslation() const handleClose = useCallback((e: React.MouseEvent) => { e.preventDefault() e.stopPropagation() @@ -19,10 +21,10 @@ export const InfoBanner: React.FC = () => { rel="noopener noreferrer" style={{ color: "var(--vscode-foreground)", outline: "none" }} target="_blank"> -

💡 Cline in the Right Sidebar

+

{t("banner.infoBanner.title")}

- Keep your files visible when chatting with Cline. Drag the Cline icon to the right sidebar panel for a better - experience. See how → + {t("banner.infoBanner.description")}{" "} + {t("banner.infoBanner.seeHow")}

{/* Close button */} diff --git a/webview-ui/src/context/ExtensionStateContext.tsx b/webview-ui/src/context/ExtensionStateContext.tsx index 539d92c1..1b5b9ade 100644 --- a/webview-ui/src/context/ExtensionStateContext.tsx +++ b/webview-ui/src/context/ExtensionStateContext.tsx @@ -199,7 +199,7 @@ export const ExtensionStateContextProvider: React.FC<{ browserSettings: DEFAULT_BROWSER_SETTINGS, dictationSettings: DEFAULT_DICTATION_SETTINGS, focusChainSettings: DEFAULT_FOCUS_CHAIN_SETTINGS, - preferredLanguage: "English", + preferredLanguage: "Simplified Chinese - 简体中文", openaiReasoningEffort: "medium", mode: "act", platform: DEFAULT_PLATFORM, diff --git a/webview-ui/src/locales/en/common.json b/webview-ui/src/locales/en/common.json index f01386a3..06d33dd5 100644 --- a/webview-ui/src/locales/en/common.json +++ b/webview-ui/src/locales/en/common.json @@ -517,5 +517,52 @@ "webFetch": "Web Fetch", "webFetchLlm": "Web Fetch (LLM)" } + }, + "banner": { + "infoBanner": { + "title": "💡 Cline in the Right Sidebar", + "description": "Keep your files visible when chatting with Cline. Drag the Cline icon to the right sidebar panel for a better experience.", + "seeHow": "See how →" + }, + "rightSidebar": { + "title": "Use Cline in Right Sidebar", + "description": "For the best experience, drag the Cline icon to your right sidebar. This keeps your file explorer and editor visible while you chat with Cline, making it easier to navigate your codebase and see changes in real-time. [See how →](https://docs.cline.bot/features/customization/opening-cline-in-sidebar)" + }, + "opus45ClineUsers": { + "title": "Claude Opus 4.5 Now Available", + "description": "State-of-the-art performance at 3x lower cost than Opus 4.1. Available now in the Cline provider.", + "tryNow": "Try Now" + }, + "opus45NonClineUsers": { + "title": "Claude Opus 4.5 Now Available", + "description": "State-of-the-art performance at 3x lower cost than Opus 4.1. Available now in the Cline provider.", + "getStarted": "Get Started" + }, + "cliInstallUnix": { + "title": "CLI & Subagents Available", + "description": "Use Cline in your terminal and enable subagent capabilities. [Learn more](https://docs.cline.bot/cline-cli/overview)", + "install": "Install", + "enableSubagents": "Enable Subagents" + }, + "cliInfoWindows": { + "title": "Cline CLI Info", + "description": "Available for macOS and Linux. Coming soon to other platforms. [Learn more](https://docs.cline.bot/cline-cli/overview)" + }, + "cliInstallBanner": { + "titleUnix": "Cline for CLI is here!", + "titleWindows": "Cline CLI Information", + "descriptionUnix": "Install to use Cline directly in your terminal and enable subagent capabilities. Cline can spawn cline commands to handle focused tasks like exploring large codebases for information. This keeps your main context window clean by running these operations in separate subprocesses.", + "descriptionWindows": "Cline CLI is available for macOS and Linux! Coming soon to other platforms.", + "learnMore": "Learn more", + "installed": "Installed", + "install": "Install", + "installCli": "Install CLI", + "enableSubagents": "Enable Subagents", + "configureSubagents": "Configure Subagents", + "subagentsWindows": "Subagents (Windows coming soon)", + "subagentsWindowsTooltip": "Cline CLI & subagents are only available on macOS & Linux", + "copyCommand": "Copy command", + "copied": "Copied!" + } } } diff --git a/webview-ui/src/locales/zh-CN/common.json b/webview-ui/src/locales/zh-CN/common.json index 57faf926..574e2bbd 100644 --- a/webview-ui/src/locales/zh-CN/common.json +++ b/webview-ui/src/locales/zh-CN/common.json @@ -517,5 +517,52 @@ "webFetch": "网页抓取", "webFetchLlm": "网页抓取 (LLM)" } + }, + "banner": { + "infoBanner": { + "title": "💡 在右侧边栏使用 Cline", + "description": "与 Cline 聊天时保持文件可见。将 Cline 图标拖到右侧边栏面板以获得更好的体验。", + "seeHow": "查看方法 →" + }, + "rightSidebar": { + "title": "在右侧边栏使用 Cline", + "description": "为了获得最佳体验,请将 Cline 图标拖到您的右侧边栏。这样可以在与 Cline 聊天时保持文件资源管理器和编辑器可见,使您更容易浏览代码库并实时查看更改。[查看方法 →](https://docs.cline.bot/features/customization/opening-cline-in-sidebar)" + }, + "opus45ClineUsers": { + "title": "Claude Opus 4.5 现已推出", + "description": "最先进的性能,成本比 Opus 4.1 低 3 倍。现已在 Cline 提供商中可用。", + "tryNow": "立即试用" + }, + "opus45NonClineUsers": { + "title": "Claude Opus 4.5 现已推出", + "description": "最先进的性能,成本比 Opus 4.1 低 3 倍。现已在 Cline 提供商中可用。", + "getStarted": "开始使用" + }, + "cliInstallUnix": { + "title": "CLI 和子代理已推出", + "description": "在终端中使用 Cline 并启用子代理功能。[了解更多](https://docs.cline.bot/cline-cli/overview)", + "install": "安装", + "enableSubagents": "启用子代理" + }, + "cliInfoWindows": { + "title": "Cline CLI 信息", + "description": "适用于 macOS 和 Linux。即将在其他平台上推出。[了解更多](https://docs.cline.bot/cline-cli/overview)" + }, + "cliInstallBanner": { + "titleUnix": "Cline CLI 已推出!", + "titleWindows": "Cline CLI 信息", + "descriptionUnix": "安装后可直接在终端中使用 Cline 并启用子代理功能。Cline 可以生成 cline 命令来处理重点任务,如探索大型代码库以获取信息。这通过在不同的子进程中运行这些操作来保持主上下文窗口整洁。", + "descriptionWindows": "Cline CLI 适用于 macOS 和 Linux!即将在其他平台上推出。", + "learnMore": "了解更多", + "installed": "已安装", + "install": "安装", + "installCli": "安装 CLI", + "enableSubagents": "启用子代理", + "configureSubagents": "配置子代理", + "subagentsWindows": "子代理(Windows 即将推出)", + "subagentsWindowsTooltip": "Cline CLI 和子代理仅在 macOS 和 Linux 上可用", + "copyCommand": "复制命令", + "copied": "已复制!" + } } }