Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Aug 25, 2025

Description

This PR addresses the issue of hardcoded error messages that were not properly internationalized in the Roo Code codebase. These messages existed in the English locale files but were still hardcoded in the source code.

Changes Made

1. Added new error message keys to English locale files

  • src/i18n/locales/en/tools.json: Added keys for tool-specific error messages
  • src/i18n/locales/en/common.json: Added keys for common error messages

2. Replaced hardcoded error messages with i18n calls

  • src/core/task/Task.ts (lines 1058, 2140): Replaced hardcoded "Roo tried to use" messages
  • src/core/tools/writeToFileTool.ts (line 148): Replaced hardcoded error message
  • src/core/tools/askFollowupQuestionTool.ts (line 51): Replaced hardcoded error
  • src/core/tools/applyDiffTool.ts (line 86): Replaced hardcoded error
  • src/core/tools/searchAndReplaceTool.ts (lines 140, 159): Replaced multiple hardcoded errors
  • src/core/tools/insertContentTool.ts (line 90): Replaced hardcoded error
  • src/core/assistant-message/presentAssistantMessage.ts (line 318): Replaced hardcoded error

3. Updated test mocks

  • src/core/tools/tests/useMcpToolTool.spec.ts: Updated mock to handle new i18n keys

Testing

  • ✅ All existing tests pass
  • ✅ Linting checks pass
  • ✅ Type checking passes
  • ✅ Verified that error messages now use the i18n system

Verification of Changes

All hardcoded error messages have been replaced with proper i18n function calls:

  • ✅ "Roo tried to use" messages now use t('tools.errors.rooTriedToUse')
  • ✅ Tool-specific errors now use appropriate i18n keys
  • ✅ Common errors use keys from common.json

Impact

This change ensures that all error messages can be properly translated to the 17+ languages supported by Roo Code. The English versions are now properly configured and can serve as the source for translation to other languages.

Next Steps

After this PR is merged, the translation team can use the translate mode to add translations for these new error messages to all supported languages.

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Comments added for complex logic (where applicable)
  • No breaking changes
  • All tests pass
  • Linting checks pass
  • Type checking passes

Important

Internationalized hardcoded error messages by replacing them with i18n calls across multiple files, enabling translation into multiple languages.

  • Behavior:
    • Replaced hardcoded error messages with i18n calls in Task.ts, writeToFileTool.ts, askFollowupQuestionTool.ts, applyDiffTool.ts, searchAndReplaceTool.ts, insertContentTool.ts, and presentAssistantMessage.ts.
    • Added new error message keys to en/tools.json and en/common.json for tool-specific and common errors.
  • Testing:
    • Updated test mocks in useMcpToolTool.spec.ts to handle new i18n keys.
    • Verified that error messages now use the i18n system.
  • Impact:
    • Ensures error messages can be translated into 17+ languages supported by Roo Code.

This description was created by Ellipsis for 11cb82a. You can customize this summary. It will automatically update as commits are pushed.

- Added new error message keys to English locale files (tools.json and common.json)
- Replaced hardcoded 'Roo tried to use' messages with i18n calls
- Replaced other hardcoded error messages in say('error') calls
- Updated test mocks to handle new i18n keys
- Affected files:
  - Task.ts: Lines 1058, 2140
  - writeToFileTool.ts: Line 148
  - askFollowupQuestionTool.ts: Line 51
  - applyDiffTool.ts: Line 86
  - searchAndReplaceTool.ts: Lines 140, 159
  - insertContentTool.ts: Line 90
  - presentAssistantMessage.ts: Line 318
  - useMcpToolTool.spec.ts: Test mock update

This change ensures all error messages can be properly translated to the 17+ languages supported by Roo Code.
Copilot AI review requested due to automatic review settings August 25, 2025 19:13
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 25, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR internationalizes hardcoded error messages throughout the Roo Code codebase by replacing them with proper i18n function calls. The changes ensure that error messages can be translated to the 17+ languages supported by Roo Code.

  • Added new error message keys to English locale files (tools.json and common.json)
  • Replaced hardcoded error messages with t() i18n function calls across multiple tool files
  • Updated test mocks to handle the new i18n keys

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/i18n/locales/en/tools.json Added tool-specific error message keys with parameter interpolation
src/i18n/locales/en/common.json Added common error message key for unexpected API responses
src/core/tools/writeToFileTool.ts Replaced hardcoded line count error with i18n call
src/core/tools/searchAndReplaceTool.ts Replaced file not found and read error messages with i18n calls
src/core/tools/insertContentTool.ts Replaced new file insertion error with i18n call
src/core/tools/askFollowupQuestionTool.ts Replaced parse operations error with i18n call
src/core/tools/applyDiffTool.ts Replaced file not found error with i18n call
src/core/tools/tests/useMcpToolTool.spec.ts Updated mock to handle new missing parameter error i18n keys
src/core/task/Task.ts Replaced missing parameter and unexpected API response errors with i18n calls
src/core/assistant-message/presentAssistantMessage.ts Replaced tool execution error with i18n call

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

"withPath": "Roo tried to use {{toolName}} for '{{relPath}}' without value for required parameter '{{paramName}}'. Retrying...",
"withoutPath": "Roo tried to use {{toolName}} without value for required parameter '{{paramName}}'. Retrying..."
},
"lineCountMissing": "Roo tried to use write_to_file{{relPath}} but the required parameter 'line_count' was missing or truncated after {{actualLineCount}} lines of content were written. Retrying...",
Copy link

Copilot AI Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space between 'write_to_file' and '{{relPath}}' placeholder. This will result in incorrect formatting when relPath is empty or when concatenating the tool name with the path.

Suggested change
"lineCountMissing": "Roo tried to use write_to_file{{relPath}} but the required parameter 'line_count' was missing or truncated after {{actualLineCount}} lines of content were written. Retrying...",
"lineCountMissing": "Roo tried to use write_to_file {{relPath}} but the required parameter 'line_count' was missing or truncated after {{actualLineCount}} lines of content were written. Retrying...",

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! I've reviewed the changes and this PR successfully addresses the internationalization of hardcoded error messages. The implementation is clean and consistent. I have some suggestions for improvement below.

"fileNotFoundSimple": "File does not exist at path: {{path}}\nThe specified file could not be found. Please verify the file path and try again.",
"fileReadError": "Error reading file: {{path}}\nFailed to read the file content: {{error}}\nPlease verify file permissions and try again.",
"insertContentNewFile": "Cannot insert content at line {{lineNumber}} into a non-existent file. For new files, 'line' must be 0 (to append) or 1 (to insert at the beginning).",
"toolExecutionError": "Error {{action}}:\n{{error}}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on adding these error message keys! The structure is clear and follows good i18n practices with parameter interpolation.

One observation: The PR description mentions that translations for the other 17 supported languages will be handled separately. Would it be helpful to create placeholder entries in the other locale files now, or track this as a follow-up task?

},
"lineCountMissing": "Roo tried to use write_to_file{{relPath}} but the required parameter 'line_count' was missing or truncated after {{actualLineCount}} lines of content were written. Retrying...",
"parseOperationsFailed": "Failed to parse operations: {{error}}",
"fileNotFound": "File does not exist at path: {{path}}\n\n<error_details>\nThe specified file could not be found. Please verify the file path and try again.\n</error_details>",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice that some error messages include HTML-like tags (<error_details>) while others don't. For consistency across the codebase, should we standardize whether error details are wrapped in these tags or not?

For example, fileNotFound includes the tags while fileNotFoundSimple doesn't.

toolName,
relPath: relPath.toPosix(),
paramName,
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactoring! The conditional logic for handling the path parameter makes the error messages more contextual. This is a good improvement over the original hardcoded message.

if (key === "tools:errors.missingRequiredParameter.withPath" && params) {
return `Roo tried to use ${params.toolName} for '${params.relPath}' without value for required parameter '${params.paramName}'. Retrying...`
}
if (key === "tools:errors.missingRequiredParameter.withoutPath" && params) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job updating the test mocks to handle the new i18n keys. This ensures the tests continue to work correctly with the internationalized messages.

"lineCountMissing": "Roo tried to use write_to_file{{relPath}} but the required parameter 'line_count' was missing or truncated after {{actualLineCount}} lines of content were written. Retrying...",
"parseOperationsFailed": "Failed to parse operations: {{error}}",
"fileNotFound": "File does not exist at path: {{path}}\n\n<error_details>\nThe specified file could not be found. Please verify the file path and try again.\n</error_details>",
"fileNotFoundSimple": "File does not exist at path: {{path}}\nThe specified file could not be found. Please verify the file path and try again.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestion: Several error messages follow similar patterns (e.g., "File does not exist at path: {{path}}"). In the future, these could potentially be further abstracted into a single parameterized message to reduce duplication. But this current approach is perfectly fine for now.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 25, 2025
"lineCountMissing": "Roo tentou usar write_to_file{{relPath}}, mas o parâmetro obrigatório 'line_count' estava ausente ou foi truncado após {{actualLineCount}} linhas de conteúdo terem sido escritas. Tentando novamente...",
"parseOperationsFailed": "Falha ao analisar operações: {{error}}",
"fileNotFound": "O arquivo não existe no caminho: {{path}}\n\n<error_details>\nO arquivo especificado não pôde ser encontrado. Verifique o caminho do arquivo e tente novamente.\n</error_details>",
"fileNotFoundSimple": "O arquivo não existe no caminho: {{path}}\nO arquivo especificado не pôde ser encontrado. Verifique o caminho do arquivo e tente novamente.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo found in the "fileNotFoundSimple" message: "не pôde ser encontrado" should be corrected to "não pôde ser encontrado".

Suggested change
"fileNotFoundSimple": "O arquivo não existe no caminho: {{path}}\nO arquivo especificado не pôde ser encontrado. Verifique o caminho do arquivo e tente novamente.",
"fileNotFoundSimple": "O arquivo não existe no caminho: {{path}}\nO arquivo especificado não pôde ser encontrado. Verifique o caminho do arquivo e tente novamente.",

"fileNotFound": "O arquivo não existe no caminho: {{path}}\n\n<error_details>\nO arquivo especificado não pôde ser encontrado. Verifique o caminho do arquivo e tente novamente.\n</error_details>",
"fileNotFoundSimple": "O arquivo não existe no caminho: {{path}}\nO arquivo especificado не pôde ser encontrado. Verifique o caminho do arquivo e tente novamente.",
"fileReadError": "Erro ao ler o arquivo: {{path}}\nFalha ao ler o conteúdo do arquivo: {{error}}\nVerifique as permissões do arquivo e tente novamente.",
"insertContentNewFile": "Não é possível inserir conteúdo на linha {{lineNumber}} em um arquivo inexistente. Para arquivos novos, 'line' deve ser 0 (para anexar) ou 1 (para inserir no início).",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo found in the "insertContentNewFile" message: "на linha" should be corrected to "na linha".

Suggested change
"insertContentNewFile": "Não é possível inserir conteúdo на linha {{lineNumber}} em um arquivo inexistente. Para arquivos novos, 'line' deve ser 0 (para anexar) ou 1 (para inserir no início).",
"insertContentNewFile": "Não é possível inserir conteúdo na linha {{lineNumber}} em um arquivo inexistente. Para arquivos novos, 'line' deve ser 0 (para anexar) ou 1 (para inserir no início).",

"withPath": "Roo 尝试在没有必需参数 '{{paramName}}' 的值的情况下对 '{{relPath}}' 使用 {{toolName}}。正在重试...",
"withoutPath": "Roo 尝试在没有必需参数 '{{paramName}}' 的值的情况下使用 {{toolName}}。正在重试..."
},
"lineCountMissing": "Roo 尝试使用 write_to_file{{relPath}},但必需的参数 'line_count' 缺失或在写入 {{actualLineCount}} 行内容后被截断。 đang thử lại...",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typographical error: The message for "lineCountMissing" includes Vietnamese text ('đang thử lại...') in a Chinese localization file. Please replace it with the appropriate Chinese translation.

Suggested change
"lineCountMissing": "Roo 尝试使用 write_to_file{{relPath}},但必需的参数 'line_count' 缺失或在写入 {{actualLineCount}} 行内容后被截断。 đang thử lại...",
"lineCountMissing": "Roo 尝试使用 write_to_file{{relPath}},但必需的参数 'line_count' 缺失或在写入 {{actualLineCount}} 行内容后被截断。正在重试...",

@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Aug 26, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Aug 26, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Aug 26, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR - Needs Preliminary Review size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants