-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: internationalize hardcoded error messages #7398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- 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.
There was a problem hiding this 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...", |
Copilot
AI
Aug 25, 2025
There was a problem hiding this comment.
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.
| "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...", |
There was a problem hiding this 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}}" |
There was a problem hiding this comment.
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>", |
There was a problem hiding this comment.
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, | ||
| }) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.", |
There was a problem hiding this comment.
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.
…ile, toolExecutionError, unexpectedApiResponse)
| "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.", |
There was a problem hiding this comment.
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".
| "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).", |
There was a problem hiding this comment.
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".
| "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...", |
There was a problem hiding this comment.
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.
| "lineCountMissing": "Roo 尝试使用 write_to_file{{relPath}},但必需的参数 'line_count' 缺失或在写入 {{actualLineCount}} 行内容后被截断。 đang thử lại...", | |
| "lineCountMissing": "Roo 尝试使用 write_to_file{{relPath}},但必需的参数 'line_count' 缺失或在写入 {{actualLineCount}} 行内容后被截断。正在重试...", |
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
2. Replaced hardcoded error messages with i18n calls
3. Updated test mocks
Testing
Verification of Changes
All hardcoded error messages have been replaced with proper i18n function calls:
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
Important
Internationalized hardcoded error messages by replacing them with i18n calls across multiple files, enabling translation into multiple languages.
Task.ts,writeToFileTool.ts,askFollowupQuestionTool.ts,applyDiffTool.ts,searchAndReplaceTool.ts,insertContentTool.ts, andpresentAssistantMessage.ts.en/tools.jsonanden/common.jsonfor tool-specific and common errors.useMcpToolTool.spec.tsto handle new i18n keys.This description was created by
for 11cb82a. You can customize this summary. It will automatically update as commits are pushed.