Skip to content

Commit a4d622a

Browse files
committed
feat: internationalize AI chat panel strings
Extract ~42 hardcoded English strings from AIChatPanel.js into src/nls/root/strings.js using AI_CHAT_* keys. Replace all in-code literals with Strings.* constants and StringUtils.format() for parameterized text. Fix a locale-sensitive bug where the Undo button click handler compared $(this).text() against English "Undo" — now uses data-action attributes instead. Pass brackets.getLocale() to the Claude agent so non-English users get responses in their display language. Add i18n guidance section to CLAUDE.md.
1 parent 98bd896 commit a4d622a

File tree

4 files changed

+123
-59
lines changed

4 files changed

+123
-59
lines changed

CLAUDE.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
- No trailing whitespace.
1414
- Use `const` and `let` instead of `var`.
1515

16+
## Translations / i18n
17+
- All user-visible strings must go in `src/nls/root/strings.js` — never hardcode English in source files.
18+
- Use `const Strings = require("strings");` then `Strings.KEY_NAME`.
19+
- For parameterized strings use `StringUtils.format(Strings.KEY, arg0, arg1)` with `{0}`, `{1}` placeholders.
20+
- Keys use UPPER_SNAKE_CASE grouped by feature prefix (e.g. `AI_CHAT_*`).
21+
- Only `src/nls/root/strings.js` (English) needs manual edits — other locales are auto-translated by GitHub Actions.
22+
- Never compare `$(el).text()` against English strings for logic — use data attributes or CSS classes instead.
23+
1624
## Phoenix MCP (Desktop App Testing)
1725

1826
Use `exec_js` to run JS in the Phoenix browser runtime. jQuery `$()` is global. `brackets.test.*` exposes internal modules (DocumentManager, CommandManager, ProjectManager, FileSystem, EditorManager). Always `return` a value from `exec_js` to see results. Prefer reusing an already-running Phoenix instance (`get_phoenix_status`) over launching a new one.

src-node/claude-code-agent.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ exports.checkAvailability = async function () {
125125
* aiProgress, aiTextStream, aiToolEdit, aiError, aiComplete
126126
*/
127127
exports.sendPrompt = async function (params) {
128-
const { prompt, projectPath, sessionAction, model } = params;
128+
const { prompt, projectPath, sessionAction, model, locale } = params;
129129
const requestId = Date.now().toString(36) + Math.random().toString(36).slice(2, 7);
130130

131131
// Handle session
@@ -142,7 +142,7 @@ exports.sendPrompt = async function (params) {
142142
currentAbortController = new AbortController();
143143

144144
// Run the query asynchronously — don't await here so we return requestId immediately
145-
_runQuery(requestId, prompt, projectPath, model, currentAbortController.signal)
145+
_runQuery(requestId, prompt, projectPath, model, currentAbortController.signal, locale)
146146
.catch(err => {
147147
console.error("[Phoenix AI] Query error:", err);
148148
});
@@ -176,7 +176,7 @@ exports.destroySession = async function () {
176176
/**
177177
* Internal: run a Claude SDK query and stream results back to the browser.
178178
*/
179-
async function _runQuery(requestId, prompt, projectPath, model, signal) {
179+
async function _runQuery(requestId, prompt, projectPath, model, signal, locale) {
180180
let editCount = 0;
181181
let toolCounter = 0;
182182
let queryFn;
@@ -209,7 +209,11 @@ async function _runQuery(requestId, prompt, projectPath, model, signal) {
209209
"to create brand new files that do not exist yet. For existing files, always use " +
210210
"multiple Edit calls to make targeted changes rather than rewriting the entire " +
211211
"file with Write. This is critical because Write replaces the entire file content " +
212-
"which is slow and loses undo history.",
212+
"which is slow and loses undo history." +
213+
(locale && !locale.startsWith("en")
214+
? "\n\nThe user's display language is " + locale + ". " +
215+
"Respond in this language unless they write in a different language."
216+
: ""),
213217
includePartialMessages: true,
214218
abortController: currentAbortController,
215219
hooks: {

0 commit comments

Comments
 (0)