diff --git a/package.nls.zh-cn.json b/package.nls.zh-cn.json index 39c8cf21..c99c7bf2 100644 --- a/package.nls.zh-cn.json +++ b/package.nls.zh-cn.json @@ -13,7 +13,7 @@ "cline.walkthrough.step5.title": "您始终拥有控制权", "cline.walkthrough.step5.description": "查看 Cline 的计划和差异。在更改发生前予以批准。没有意外。", "cline.command.newTask": "新任务", - "cline.command.mcpServers": "MCP 服务端", + "cline.command.mcpServers": "MCP 服务器", "cline.command.history": "历史记录", "cline.command.account": "账户", "cline.command.settings": "设置", @@ -27,4 +27,3 @@ "cline.command.openWalkthrough": "打开入门教程", "cline.command.reconstructTaskHistory": "重建任务历史" } - diff --git a/src/core/task/tools/handlers/ExecuteCommandToolHandler.ts b/src/core/task/tools/handlers/ExecuteCommandToolHandler.ts index 34082102..5ba1d6ee 100644 --- a/src/core/task/tools/handlers/ExecuteCommandToolHandler.ts +++ b/src/core/task/tools/handlers/ExecuteCommandToolHandler.ts @@ -222,9 +222,16 @@ export class ExecuteCommandToolHandler implements IFullyManagedTool { if (didAutoApprove && config.autoApprovalSettings.enableNotifications) { // if the command was auto-approved, and it's long running we need to notify the user after some time has passed without proceeding timeoutId = setTimeout(() => { + const preferredLanguage = config.services.stateManager.getGlobalSettingsKey("preferredLanguage") + const isChinese = + preferredLanguage === "Simplified Chinese - 简体中文" || + preferredLanguage === "zh-CN" || + preferredLanguage === "zh-TW" showSystemNotification({ - subtitle: "Command is still running", - message: "An auto-approved command has been running for 30s, and may need your attention.", + subtitle: isChinese ? "命令仍在运行" : "Command is still running", + message: isChinese + ? "一个自动批准的命令已运行 30 秒,可能需要您的注意。" + : "An auto-approved command has been running for 30s, and may need your attention.", }) }, 30_000) } diff --git a/webview-ui/src/components/chat/ServersToggleModal.tsx b/webview-ui/src/components/chat/ServersToggleModal.tsx index a5a22707..dbf51507 100644 --- a/webview-ui/src/components/chat/ServersToggleModal.tsx +++ b/webview-ui/src/components/chat/ServersToggleModal.tsx @@ -3,6 +3,7 @@ import { McpServers } from "@shared/proto/cline/mcp" import { convertProtoMcpServersToMcpServers } from "@shared/proto-conversions/mcp/mcp-server-conversion" import { VSCodeButton } from "@vscode/webview-ui-toolkit/react" import React, { useEffect, useRef, useState } from "react" +import { useTranslation } from "react-i18next" import { useClickAway, useWindowSize } from "react-use" import PopupModalContainer from "@/components/common/PopupModalContainer" import ServersToggleList from "@/components/mcp/configuration/tabs/installed/ServersToggleList" @@ -11,6 +12,7 @@ import { useExtensionState } from "@/context/ExtensionStateContext" import { McpServiceClient } from "@/services/grpc-client" const ServersToggleModal: React.FC = () => { + const { t } = useTranslation() const { mcpServers, navigateToMcp, setMcpServers } = useExtensionState() const [isVisible, setIsVisible] = useState(false) const buttonRef = useRef(null) @@ -55,11 +57,11 @@ const ServersToggleModal: React.FC = () => {
- {!isVisible && Manage MCP Servers} + {!isVisible && {t("mcp.serversToggle.manageServers")}} setIsVisible(!isVisible)}> @@ -72,10 +74,10 @@ const ServersToggleModal: React.FC = () => {
-
MCP Servers
+
{t("mcp.title")}
{ setIsVisible(false) navigateToMcp("configure") diff --git a/webview-ui/src/components/chat/auto-approve-menu/AutoApproveBar.tsx b/webview-ui/src/components/chat/auto-approve-menu/AutoApproveBar.tsx index 2de1b76f..9879914d 100644 --- a/webview-ui/src/components/chat/auto-approve-menu/AutoApproveBar.tsx +++ b/webview-ui/src/components/chat/auto-approve-menu/AutoApproveBar.tsx @@ -1,4 +1,5 @@ import { useRef, useState } from "react" +import { useTranslation } from "react-i18next" import { useExtensionState } from "@/context/ExtensionStateContext" import { getAsVar, VSC_TITLEBAR_INACTIVE_FOREGROUND } from "@/utils/vscStyles" import AutoApproveModal from "./AutoApproveModal" @@ -9,6 +10,7 @@ interface AutoApproveBarProps { } const AutoApproveBar = ({ style }: AutoApproveBarProps) => { + const { t } = useTranslation() const { autoApprovalSettings, yoloModeToggled, navigateToSettings } = useExtensionState() const [isModalVisible, setIsModalVisible] = useState(false) @@ -46,17 +48,38 @@ const AutoApproveBar = ({ style }: AutoApproveBarProps) => { }) if (actionsToShow.length === 0) { - return None + return {t("autoApprove.bar.none")} + } + + // 根据 action.id 获取翻译键 + const getShortNameTranslationKey = (id: string): string => { + const keyMap: Record = { + readFiles: "autoApprove.actions.shortNames.readFiles", + readFilesExternally: "autoApprove.actions.shortNames.readFilesExternally", + editFiles: "autoApprove.actions.shortNames.editFiles", + editFilesExternally: "autoApprove.actions.shortNames.editFilesExternally", + executeSafeCommands: "autoApprove.actions.shortNames.executeSafeCommands", + executeAllCommands: "autoApprove.actions.shortNames.executeAllCommands", + useBrowser: "autoApprove.actions.shortNames.useBrowser", + useMcp: "autoApprove.actions.shortNames.useMcp", + } + return keyMap[id] || "" } return ( - {actionsToShow.map((action, index) => ( - - {action?.shortName} - {index < actionsToShow.length - 1 && ", "} - - ))} + {actionsToShow.map((action, index) => { + const translationKey = getShortNameTranslationKey(action?.id || "") + const displayText = translationKey + ? t(translationKey, { defaultValue: action?.shortName }) + : action?.shortName + return ( + + {displayText} + {index < actionsToShow.length - 1 && ", "} + + ) + })} ) } @@ -99,11 +122,11 @@ const AutoApproveBar = ({ style }: AutoApproveBarProps) => { />
-
Auto-approve: YOLO
+
{t("autoApprove.bar.yoloTitle")}
- YOLO mode is enabled.{" "} + {t("autoApprove.bar.yoloDescription")}{" "} - Disable it in Settings + {t("autoApprove.bar.disableInSettings")} .
@@ -143,7 +166,7 @@ const AutoApproveBar = ({ style }: AutoApproveBarProps) => { />
{ setIsModalVisible((prev) => !prev) @@ -158,7 +181,7 @@ const AutoApproveBar = ({ style }: AutoApproveBarProps) => { ref={buttonRef} tabIndex={0}>
- Auto-approve: + {t("autoApprove.bar.title")} {getEnabledActionsText()}
{isModalVisible ? ( diff --git a/webview-ui/src/components/chat/auto-approve-menu/AutoApproveMenuItem.tsx b/webview-ui/src/components/chat/auto-approve-menu/AutoApproveMenuItem.tsx index 9ed1766c..14cfff8b 100644 --- a/webview-ui/src/components/chat/auto-approve-menu/AutoApproveMenuItem.tsx +++ b/webview-ui/src/components/chat/auto-approve-menu/AutoApproveMenuItem.tsx @@ -1,4 +1,5 @@ import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react" +import { useTranslation } from "react-i18next" import styled from "styled-components" import { ActionMetadata } from "./types" @@ -29,8 +30,26 @@ const CheckboxWrapper = styled.div<{ $disabled: boolean }>` ` const AutoApproveMenuItem = ({ action, isChecked, onToggle, showIcon = true, disabled = false }: AutoApproveMenuItemProps) => { + const { t } = useTranslation() const checked = isChecked(action) + // 根据 action.id 获取翻译键 + const getLabelTranslationKey = (id: string): string => { + const keyMap: Record = { + readFiles: "autoApprove.actions.readProjectFiles", + readFilesExternally: "autoApprove.actions.readAllFiles", + editFiles: "autoApprove.actions.editProjectFiles", + editFilesExternally: "autoApprove.actions.editAllFiles", + executeSafeCommands: "autoApprove.actions.executeSafeCommands", + executeAllCommands: "autoApprove.actions.executeAllCommands", + useBrowser: "autoApprove.actions.useBrowser", + useMcp: "autoApprove.actions.useMcpServers", + } + return keyMap[id] || action.label + } + + const translatedLabel = getLabelTranslationKey(action.id) + const onChange = async (e: React.MouseEvent) => { if (disabled) { return @@ -45,7 +64,7 @@ const AutoApproveMenuItem = ({ action, isChecked, onToggle, showIcon = true, dis
{showIcon && } - {action.label} + {t(translatedLabel, { defaultValue: action.label })}
diff --git a/webview-ui/src/components/chat/auto-approve-menu/AutoApproveModal.tsx b/webview-ui/src/components/chat/auto-approve-menu/AutoApproveModal.tsx index 515cd627..4a760671 100644 --- a/webview-ui/src/components/chat/auto-approve-menu/AutoApproveModal.tsx +++ b/webview-ui/src/components/chat/auto-approve-menu/AutoApproveModal.tsx @@ -1,5 +1,6 @@ import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react" import React, { useEffect, useRef, useState } from "react" +import { useTranslation } from "react-i18next" import { useClickAway } from "react-use" import { useExtensionState } from "@/context/ExtensionStateContext" import { useAutoApproveActions } from "@/hooks/useAutoApproveActions" @@ -18,6 +19,7 @@ interface AutoApproveModalProps { } const AutoApproveModal: React.FC = ({ isVisible, setIsVisible, buttonRef, ACTION_METADATA }) => { + const { t } = useTranslation() const { autoApprovalSettings } = useExtensionState() const { isChecked, updateAction } = useAutoApproveActions() const modalRef = useRef(null) @@ -72,14 +74,14 @@ const AutoApproveModal: React.FC = ({ isVisible, setIsVis maxHeight: "60vh", }}>
setIsVisible(false)}> - Let Cline take these actions without asking for approval.{" "} + {t("autoApprove.modal.description")}{" "} - Docs + {t("autoApprove.modal.docs")}
@@ -129,7 +131,7 @@ const AutoApproveModal: React.FC = ({ isVisible, setIsVis enableNotifications: checked, }) }}> - Enable notifications + {t("autoApprove.modal.enableNotifications")}
diff --git a/webview-ui/src/components/cline-rules/ClineRulesToggleModal.tsx b/webview-ui/src/components/cline-rules/ClineRulesToggleModal.tsx index 1ba5c2b8..25a5120f 100644 --- a/webview-ui/src/components/cline-rules/ClineRulesToggleModal.tsx +++ b/webview-ui/src/components/cline-rules/ClineRulesToggleModal.tsx @@ -11,6 +11,7 @@ import { } from "@shared/proto/cline/file" import { VSCodeButton, VSCodeLink } from "@vscode/webview-ui-toolkit/react" import React, { useEffect, useRef, useState } from "react" +import { useTranslation } from "react-i18next" import { useClickAway, useWindowSize } from "react-use" import styled from "styled-components" import PopupModalContainer from "@/components/common/PopupModalContainer" @@ -24,6 +25,7 @@ import RuleRow from "./RuleRow" import RulesToggleList from "./RulesToggleList" const ClineRulesToggleModal: React.FC = () => { + const { t } = useTranslation() const { globalClineRulesToggles = {}, localClineRulesToggles = {}, @@ -362,11 +364,11 @@ const ClineRulesToggleModal: React.FC = () => {
- {!isVisible && Manage Cline Rules & Workflows} + {!isVisible && {t("clineRules.manageRulesAndWorkflows")}} setIsVisible(!isVisible)}> @@ -393,14 +395,14 @@ const ClineRulesToggleModal: React.FC = () => { borderBottom: "1px solid var(--vscode-panel-border)", }}> setCurrentView("rules")}> - Rules + {t("clineRules.tabs.rules")} setCurrentView("workflows")}> - Workflows + {t("clineRules.tabs.workflows")} {hooksEnabled && ( setCurrentView("hooks")}> - Hooks + {t("clineRules.tabs.hooks")} )}
@@ -412,8 +414,8 @@ const ClineRulesToggleModal: React.FC = () => { {currentView === "rules" - ? "Your organization manages some rules" - : "Your organization manages some workflows"} + ? t("clineRules.remoteBanner.rules") + : t("clineRules.remoteBanner.workflows")}
) : null} @@ -422,31 +424,27 @@ const ClineRulesToggleModal: React.FC = () => {
{currentView === "rules" ? (

- Rules allow you to provide Cline with system-level guidance. Think of them as a persistent way - to include context and preferences for your projects or globally for every conversation.{" "} + {t("clineRules.descriptions.rules")}{" "} - Docs + {t("clineRules.docs")}

) : currentView === "workflows" ? (

- Workflows allow you to define a series of steps to guide Cline through a repetitive set of - tasks, such as deploying a service or submitting a PR. To invoke a workflow, type{" "} - /workflow-name in the chat.{" "} + {t("clineRules.descriptions.workflows")}{" "} + /workflow-name{" "} + {t("clineRules.descriptions.workflowsInvoke")}{" "} - Docs + {t("clineRules.docs")}

) : ( -

- Hooks allow you to execute custom scripts at specific points in Cline's execution lifecycle, - enabling automation and integration with external tools. -

+

{t("clineRules.descriptions.hooks")}

)}
@@ -458,7 +456,7 @@ const ClineRulesToggleModal: React.FC = () => { {/* Remote Rules Section */} {hasRemoteRules && (
-
Enterprise Rules
+
{t("clineRules.sections.enterpriseRules")}
{remoteGlobalRules.map((rule) => { const enabled = rule.alwaysEnabled || remoteRulesToggles[rule.name] === true @@ -481,7 +479,7 @@ const ClineRulesToggleModal: React.FC = () => { {/* Global Rules Section */}
-
Global Rules
+
{t("clineRules.sections.globalRules")}
{/* File-based Global Rules */} { {/* Local Rules Section */}
-
Workspace Rules
+
{t("clineRules.sections.workspaceRules")}
{ {/* Remote Workflows Section */} {hasRemoteWorkflows && (
-
Enterprise Workflows
+
+ {t("clineRules.sections.enterpriseWorkflows")} +
{remoteGlobalWorkflows.map((workflow) => { const enabled = @@ -566,7 +566,7 @@ const ClineRulesToggleModal: React.FC = () => { {/* Global Workflows Section */}
-
Global Workflows
+
{t("clineRules.sections.globalWorkflows")}
{/* File-based Global Workflows */} { {/* Local Workflows Section */}
-
Workspace Workflows
+
{t("clineRules.sections.workspaceWorkflows")}
{ <>

- Toggle to enable/disable (chmod +x/-x).{" "} + {t("clineRules.descriptions.hooksToggle")}{" "} - Docs + {t("clineRules.docs")}

@@ -612,16 +612,13 @@ const ClineRulesToggleModal: React.FC = () => { {isWindows && (
- - Hook toggling is not supported on Windows. Hooks can be created, edited, and deleted, - but cannot be enabled/disabled and will not execute. - + {t("clineRules.hooks.windowsWarning")}
)} {/* Global Hooks */}
-
Global Hooks
+
{t("clineRules.sections.globalHooks")}
{globalHooks .sort((a, b) => a.name.localeCompare(b.name)) diff --git a/webview-ui/src/components/cline-rules/HookRow.tsx b/webview-ui/src/components/cline-rules/HookRow.tsx index 94352063..a479afec 100644 --- a/webview-ui/src/components/cline-rules/HookRow.tsx +++ b/webview-ui/src/components/cline-rules/HookRow.tsx @@ -1,6 +1,7 @@ import { StringRequest } from "@shared/proto/cline/common" import { DeleteHookRequest, HooksToggles } from "@shared/proto/cline/file" import { PenIcon, Trash2Icon } from "lucide-react" +import { useTranslation } from "react-i18next" import { Button } from "@/components/ui/button" import { Switch } from "@/components/ui/switch" import { FileServiceClient } from "@/services/grpc-client" @@ -26,6 +27,7 @@ const HookRow: React.FC = ({ onToggle, onDelete, }) => { + const { t } = useTranslation() const handleEditClick = () => { FileServiceClient.openFile(StringRequest.create({ value: absolutePath })).catch((err) => console.error("Failed to open file:", err), @@ -57,12 +59,7 @@ const HookRow: React.FC = ({ {/* Toggle Switch */}
-
+
= ({ style={isWindows ? { opacity: 0.5, cursor: "not-allowed" } : undefined} />
- diff --git a/webview-ui/src/components/cline-rules/NewRuleRow.tsx b/webview-ui/src/components/cline-rules/NewRuleRow.tsx index 63f47ab7..437f94a0 100644 --- a/webview-ui/src/components/cline-rules/NewRuleRow.tsx +++ b/webview-ui/src/components/cline-rules/NewRuleRow.tsx @@ -1,6 +1,7 @@ import { CreateHookRequest, RuleFileRequest } from "@shared/proto/index.cline" import { PlusIcon } from "lucide-react" import { useEffect, useMemo, useRef, useState } from "react" +import { useTranslation } from "react-i18next" import { useClickAway } from "react-use" import { Button } from "@/components/ui/button" import { cn } from "@/lib/utils" @@ -25,6 +26,7 @@ const HOOK_TYPES = [ ] const NewRuleRow: React.FC = ({ isGlobal, ruleType, existingHooks = [], workspaceName }) => { + const { t } = useTranslation() const [isExpanded, setIsExpanded] = useState(false) const [filename, setFilename] = useState("") const inputRef = useRef(null) @@ -86,7 +88,7 @@ const NewRuleRow: React.FC = ({ isGlobal, ruleType, existingHoo const extension = getExtension(trimmedFilename) if (!isValidExtension(extension)) { - setError("Only .md, .txt, or no file extension allowed") + setError(t("clineRules.newRuleRow.invalidExtension")) return } @@ -139,15 +141,14 @@ const NewRuleRow: React.FC = ({ isGlobal, ruleType, existingHoo {ruleType === "hook" ? ( <> - Choose a hook type to create. Hooks execute at specific points in Cline's lifecycle. Available:{" "} - {availableHookTypes.map((h) => h.name).join(", ")} + {t("clineRules.hooks.chooseHookType")} {availableHookTypes.map((h) => h.name).join(", ")}