chore(i18n): use t() for tool messages; add generic noChanges/changesRejected; execCommand/fetchInstructions i18n

This commit is contained in:
Hannes Rudolph 2025-09-03 16:33:36 -06:00
parent bacedd6897
commit 72c79ce0e9
4 changed files with 16 additions and 9 deletions

View file

@ -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

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}