From 72c79ce0e938512d3ba8b030fa19d7eba10f315e Mon Sep 17 00:00:00 2001 From: Hannes Rudolph Date: Wed, 3 Sep 2025 16:33:36 -0600 Subject: [PATCH] chore(i18n): use t() for tool messages; add generic noChanges/changesRejected; execCommand/fetchInstructions i18n --- src/core/tools/executeCommandTool.ts | 4 ++-- src/core/tools/fetchInstructionsTool.ts | 8 +++++++- src/core/tools/insertContentTool.ts | 4 ++-- src/core/tools/searchAndReplaceTool.ts | 9 +++++---- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/core/tools/executeCommandTool.ts b/src/core/tools/executeCommandTool.ts index 032cac5579..4367075259 100644 --- a/src/core/tools/executeCommandTool.ts +++ b/src/core/tools/executeCommandTool.ts @@ -126,7 +126,7 @@ export async function executeCommandTool( pushToolResult(result) } else { - pushToolResult(`Command failed to execute in terminal due to a shell integration error.`) + pushToolResult(t("tools:executeCommand.shellIntegrationGenericError")) } } @@ -175,7 +175,7 @@ export async function executeCommand( try { await fs.access(workingDir) } catch (error) { - return [false, `Working directory '${workingDir}' does not exist.`] + return [false, t("tools:executeCommand.workingDirMissing", { workingDir })] } let message: { text?: string; images?: string[] } | undefined diff --git a/src/core/tools/fetchInstructionsTool.ts b/src/core/tools/fetchInstructionsTool.ts index 412101a7f2..704e8a3cb1 100644 --- a/src/core/tools/fetchInstructionsTool.ts +++ b/src/core/tools/fetchInstructionsTool.ts @@ -3,6 +3,7 @@ import { fetchInstructions } from "../prompts/instructions/instructions" import { ClineSayTool } from "../../shared/ExtensionMessage" import { formatResponse } from "../prompts/responses" import { ToolUse, AskApproval, HandleError, PushToolResult } from "../../shared/tools" +import { t } from "../../i18n" export async function fetchInstructionsTool( cline: Task, @@ -49,7 +50,12 @@ export async function fetchInstructionsTool( const content = await fetchInstructions(task, { mcpHub, diffStrategy, context }) if (!content) { - pushToolResult(formatResponse.toolError(`Invalid instructions request: ${task}`, "fetch_instructions")) + pushToolResult( + formatResponse.toolError( + t("tools:fetchInstructions.errors.invalidRequest", { defaultValue: "Invalid request" }), + "fetch_instructions", + ), + ) return } diff --git a/src/core/tools/insertContentTool.ts b/src/core/tools/insertContentTool.ts index 7935144553..2fc2d523f7 100644 --- a/src/core/tools/insertContentTool.ts +++ b/src/core/tools/insertContentTool.ts @@ -131,7 +131,7 @@ export async function insertContentTool( // For existing files, generate diff and check for changes diff = formatResponse.createPrettyPatch(relPath, fileContent, updatedContent) if (!diff) { - pushToolResult(`No changes needed for '${relPath}'`) + pushToolResult(t("tools:generic.noChanges")) return } approvalContent = undefined @@ -165,7 +165,7 @@ export async function insertContentTool( if (!isPreventFocusDisruptionEnabled) { await cline.diffViewProvider.revertChanges() } - pushToolResult("Changes were rejected by the user.") + pushToolResult(t("tools:generic.changesRejected")) await cline.diffViewProvider.reset() return } diff --git a/src/core/tools/searchAndReplaceTool.ts b/src/core/tools/searchAndReplaceTool.ts index 36bfa3745b..1f13e0847f 100644 --- a/src/core/tools/searchAndReplaceTool.ts +++ b/src/core/tools/searchAndReplaceTool.ts @@ -13,6 +13,7 @@ import { fileExistsAtPath } from "../../utils/fs" import { RecordSource } from "../context-tracking/FileContextTrackerTypes" import { DEFAULT_WRITE_DELAY_MS } from "@roo-code/types" import { EXPERIMENT_IDS, experiments } from "../../shared/experiments" +import { t } from "../../i18n" /** * Tool for performing search and replace operations on files @@ -138,7 +139,7 @@ export async function searchAndReplaceTool( `File does not exist at path: ${absolutePath}\nThe specified file could not be found. Please verify the file path and try again.`, ) await cline.say("error", formattedError, undefined, undefined, undefined, undefined, { - title: "File Not Found", + title: t("tools:errors.fileNotFound"), }) pushToolResult(formattedError) return @@ -159,7 +160,7 @@ export async function searchAndReplaceTool( }\nPlease verify file permissions and try again.` const formattedError = formatResponse.toolError(errorMessage) await cline.say("error", formattedError, undefined, undefined, undefined, undefined, { - title: "File Read Error", + title: t("tools:errors.readError"), }) pushToolResult(formattedError) return @@ -199,7 +200,7 @@ export async function searchAndReplaceTool( // Generate and validate diff const diff = formatResponse.createPrettyPatch(validRelPath, fileContent, newContent) if (!diff) { - pushToolResult(`No changes needed for '${relPath}'`) + pushToolResult(t("tools:generic.noChanges")) await cline.diffViewProvider.reset() return } @@ -234,7 +235,7 @@ export async function searchAndReplaceTool( if (!isPreventFocusDisruptionEnabled) { await cline.diffViewProvider.revertChanges() } - pushToolResult("Changes were rejected by the user.") + pushToolResult(t("tools:generic.changesRejected")) await cline.diffViewProvider.reset() return }