Skip to content

Commit 227b1cd

Browse files
rrewllclaude
andcommitted
fix(ui): translate remaining hardcoded labels (Zoo-Code-Org#2425)
Route the remaining hardcoded user-facing strings in the webview through i18n keys in all 18 locales: the auto-approve dropdown toggle, the todo list tool block, Zoo Code auth badge, @-mention context menu, Qwen/OpenAI/Bedrock provider settings, MCP server restriction, marketplace tabs, model info units and more. Screen-reader labels: drop aria-labels that duplicated visible text or placeholders, drop labels on decorative ChatRow icons, and translate the labels that are an element's only accessible name. Keys used only by screen readers are named *AriaLabel. Counted strings use CLDR plural forms (diff hidden lines, the file-changes header, model token counts). Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent f2b4d1c commit 227b1cd

178 files changed

Lines changed: 2571 additions & 499 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎webview-ui/playwright/gallery/stories.tsx‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,12 @@ export const stories: Record<string, Story> = {
367367
return <TelemetryBannerFixture />
368368
},
369369
"theme-aware-controls": async () => {
370-
const [{ SelectDropdown }, { default: UpdateTodoListToolBlock }] = await Promise.all([
371-
import("@/components/ui/select-dropdown"),
372-
import("@/components/chat/UpdateTodoListToolBlock"),
373-
])
370+
const [{ SelectDropdown }, { default: UpdateTodoListToolBlock }, { EnglishChatTranslations }] =
371+
await Promise.all([
372+
import("@/components/ui/select-dropdown"),
373+
import("@/components/chat/UpdateTodoListToolBlock"),
374+
import("@/components/chat/__tests__/UpdateTodoListToolBlock.visual.fixture"),
375+
])
374376
type Todo = NonNullable<React.ComponentProps<typeof UpdateTodoListToolBlock>["todos"]>[number]
375377

376378
function ThemeAwareControlsStory() {
@@ -381,7 +383,9 @@ export const stories: Record<string, Story> = {
381383
return (
382384
<div className="flex flex-col gap-4 w-96">
383385
<SelectDropdown value={value} options={[{ value: "code", label: "Code" }]} onChange={setValue} />
384-
<UpdateTodoListToolBlock todos={todos} onChange={setTodos} />
386+
<EnglishChatTranslations>
387+
<UpdateTodoListToolBlock todos={todos} onChange={setTodos} />
388+
</EnglishChatTranslations>
385389
</div>
386390
)
387391
}

‎webview-ui/src/__tests__/command-autocomplete.spec.ts‎

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import type { TFunction } from "i18next"
2+
13
import type { Command } from "@roo-code/types"
24

35
import { getContextMenuOptions, ContextMenuOptionType } from "../utils/context-mentions"
46

7+
const t = ((key: string) => key) as TFunction
8+
59
describe("Command Autocomplete", () => {
610
const mockCommands: Command[] = [
711
{ name: "setup", source: "project" },
@@ -19,7 +23,7 @@ describe("Command Autocomplete", () => {
1923

2024
describe("slash command command suggestions", () => {
2125
it('should return all commands when query is just "/"', () => {
22-
const options = getContextMenuOptions("/", null, mockQueryItems, [], [], mockCommands)
26+
const options = getContextMenuOptions(t, "/", null, mockQueryItems, [], [], mockCommands)
2327

2428
// Should have 7 items: 1 section header + 6 commands
2529
expect(options).toHaveLength(7)
@@ -38,7 +42,7 @@ describe("Command Autocomplete", () => {
3842
})
3943

4044
it("should filter commands based on fuzzy search", () => {
41-
const options = getContextMenuOptions("/set", null, mockQueryItems, [], [], mockCommands)
45+
const options = getContextMenuOptions(t, "/set", null, mockQueryItems, [], [], mockCommands)
4246

4347
// Should match 'setup' (fuzzy search behavior may vary)
4448
expect(options.length).toBeGreaterThan(0)
@@ -48,7 +52,7 @@ describe("Command Autocomplete", () => {
4852
})
4953

5054
it("should return commands with correct format", () => {
51-
const options = getContextMenuOptions("/setup", null, mockQueryItems, [], [], mockCommands)
55+
const options = getContextMenuOptions(t, "/setup", null, mockQueryItems, [], [], mockCommands)
5256

5357
const setupOption = options.find((option) => option.value === "setup")
5458
expect(setupOption).toBeDefined()
@@ -58,23 +62,23 @@ describe("Command Autocomplete", () => {
5862
})
5963

6064
it("should handle empty command list", () => {
61-
const options = getContextMenuOptions("/setup", null, mockQueryItems, [], [], [])
65+
const options = getContextMenuOptions(t, "/setup", null, mockQueryItems, [], [], [])
6266

6367
// Should return NoResults when no commands match
6468
expect(options).toHaveLength(1)
6569
expect(options[0].type).toBe(ContextMenuOptionType.NoResults)
6670
})
6771

6872
it("should handle no matching commands", () => {
69-
const options = getContextMenuOptions("/nonexistent", null, mockQueryItems, [], [], mockCommands)
73+
const options = getContextMenuOptions(t, "/nonexistent", null, mockQueryItems, [], [], mockCommands)
7074

7175
// Should return NoResults when no commands match
7276
expect(options).toHaveLength(1)
7377
expect(options[0].type).toBe(ContextMenuOptionType.NoResults)
7478
})
7579

7680
it("should not return command suggestions for non-slash queries", () => {
77-
const options = getContextMenuOptions("setup", null, mockQueryItems, [], [], mockCommands)
81+
const options = getContextMenuOptions(t, "setup", null, mockQueryItems, [], [], mockCommands)
7882

7983
// Should not contain command options for non-slash queries
8084
const commandOptions = options.filter((option) => option.type === ContextMenuOptionType.Command)
@@ -88,15 +92,15 @@ describe("Command Autocomplete", () => {
8892
{ name: "deploy.prod", source: "global" },
8993
]
9094

91-
const options = getContextMenuOptions("/setup", null, mockQueryItems, [], [], specialCommands)
95+
const options = getContextMenuOptions(t, "/setup", null, mockQueryItems, [], [], specialCommands)
9296

9397
const setupDevOption = options.find((option) => option.value === "setup-dev")
9498
expect(setupDevOption).toBeDefined()
9599
expect(setupDevOption!.slashCommand).toBe("/setup-dev")
96100
})
97101

98102
it("should handle case-insensitive fuzzy matching", () => {
99-
const options = getContextMenuOptions("/setup", null, mockQueryItems, [], [], mockCommands)
103+
const options = getContextMenuOptions(t, "/setup", null, mockQueryItems, [], [], mockCommands)
100104

101105
const commandNames = options.map((option) => option.value)
102106
expect(commandNames).toContain("setup")
@@ -109,15 +113,15 @@ describe("Command Autocomplete", () => {
109113
{ name: "integration-test", source: "project" },
110114
]
111115

112-
const options = getContextMenuOptions("/test", null, mockQueryItems, [], [], commandsWithSimilarNames)
116+
const options = getContextMenuOptions(t, "/test", null, mockQueryItems, [], [], commandsWithSimilarNames)
113117

114118
// Filter out section headers and check the first command
115119
const commandOptions = options.filter((option) => option.type === ContextMenuOptionType.Command)
116120
expect(commandOptions[0].value).toBe("test")
117121
})
118122

119123
it("should handle partial matches correctly", () => {
120-
const options = getContextMenuOptions("/te", null, mockQueryItems, [], [], mockCommands)
124+
const options = getContextMenuOptions(t, "/te", null, mockQueryItems, [], [], mockCommands)
121125

122126
// Should match 'test-suite'
123127
const commandNames = options.map((option) => option.value)
@@ -144,7 +148,7 @@ describe("Command Autocomplete", () => {
144148
] as any[]
145149

146150
it("should return both modes and commands for slash commands", () => {
147-
const options = getContextMenuOptions("/", null, mockQueryItems, [], mockModes, mockCommands)
151+
const options = getContextMenuOptions(t, "/", null, mockQueryItems, [], mockModes, mockCommands)
148152

149153
const modeOptions = options.filter((option) => option.type === ContextMenuOptionType.Mode)
150154
const commandOptions = options.filter((option) => option.type === ContextMenuOptionType.Command)
@@ -154,7 +158,7 @@ describe("Command Autocomplete", () => {
154158
})
155159

156160
it("should filter both modes and commands based on query", () => {
157-
const options = getContextMenuOptions("/co", null, mockQueryItems, [], mockModes, mockCommands)
161+
const options = getContextMenuOptions(t, "/co", null, mockQueryItems, [], mockModes, mockCommands)
158162

159163
// Should match 'code' mode and possibly some commands (fuzzy search may match)
160164
const modeOptions = options.filter((option) => option.type === ContextMenuOptionType.Mode)
@@ -169,7 +173,7 @@ describe("Command Autocomplete", () => {
169173

170174
describe("command source indication", () => {
171175
it("should not expose source information in autocomplete", () => {
172-
const options = getContextMenuOptions("/setup", null, mockQueryItems, [], [], mockCommands)
176+
const options = getContextMenuOptions(t, "/setup", null, mockQueryItems, [], [], mockCommands)
173177

174178
const setupOption = options.find((option) => option.value === "setup")
175179
expect(setupOption).toBeDefined()
@@ -185,23 +189,23 @@ describe("Command Autocomplete", () => {
185189

186190
describe("argument hint functionality", () => {
187191
it("should include argumentHint in command options when present", () => {
188-
const options = getContextMenuOptions("/release", null, mockQueryItems, [], [], mockCommands)
192+
const options = getContextMenuOptions(t, "/release", null, mockQueryItems, [], [], mockCommands)
189193

190194
const releaseOption = options.find((option) => option.value === "release")
191195
expect(releaseOption).toBeDefined()
192196
expect(releaseOption!.argumentHint).toBe("patch | minor | major")
193197
})
194198

195199
it("should handle commands without argumentHint", () => {
196-
const options = getContextMenuOptions("/setup", null, mockQueryItems, [], [], mockCommands)
200+
const options = getContextMenuOptions(t, "/setup", null, mockQueryItems, [], [], mockCommands)
197201

198202
const setupOption = options.find((option) => option.value === "setup")
199203
expect(setupOption).toBeDefined()
200204
expect(setupOption!.argumentHint).toBeUndefined()
201205
})
202206

203207
it("should preserve argumentHint through fuzzy search", () => {
204-
const options = getContextMenuOptions("/rel", null, mockQueryItems, [], [], mockCommands)
208+
const options = getContextMenuOptions(t, "/rel", null, mockQueryItems, [], [], mockCommands)
205209

206210
const releaseOption = options.find((option) => option.value === "release")
207211
expect(releaseOption).toBeDefined()
@@ -211,7 +215,7 @@ describe("Command Autocomplete", () => {
211215
it("should handle commands with empty argumentHint", () => {
212216
const commandsWithEmptyHint: Command[] = [{ name: "test-command", source: "project", argumentHint: "" }]
213217

214-
const options = getContextMenuOptions("/test", null, mockQueryItems, [], [], commandsWithEmptyHint)
218+
const options = getContextMenuOptions(t, "/test", null, mockQueryItems, [], [], commandsWithEmptyHint)
215219

216220
const testOption = options.find((option) => option.value === "test-command")
217221
expect(testOption).toBeDefined()
@@ -221,14 +225,14 @@ describe("Command Autocomplete", () => {
221225

222226
describe("edge cases", () => {
223227
it("should handle undefined commands gracefully", () => {
224-
const options = getContextMenuOptions("/setup", null, mockQueryItems, [], [], undefined)
228+
const options = getContextMenuOptions(t, "/setup", null, mockQueryItems, [], [], undefined)
225229

226230
expect(options).toHaveLength(1)
227231
expect(options[0].type).toBe(ContextMenuOptionType.NoResults)
228232
})
229233

230234
it("should handle empty query with commands", () => {
231-
const options = getContextMenuOptions("", null, mockQueryItems, [], [], mockCommands)
235+
const options = getContextMenuOptions(t, "", null, mockQueryItems, [], [], mockCommands)
232236

233237
// Should not return command options for empty query
234238
const commandOptions = options.filter((option) => option.type === ContextMenuOptionType.Command)
@@ -240,7 +244,7 @@ describe("Command Autocomplete", () => {
240244
{ name: "very-long-command-name-that-exceeds-normal-length", source: "project" },
241245
]
242246

243-
const options = getContextMenuOptions("/very", null, mockQueryItems, [], [], longNameCommands)
247+
const options = getContextMenuOptions(t, "/very", null, mockQueryItems, [], [], longNameCommands)
244248

245249
// Should have 2 items: 1 section header + 1 command
246250
expect(options.length).toBe(2)
@@ -255,7 +259,7 @@ describe("Command Autocomplete", () => {
255259
{ name: "123test", source: "project" },
256260
]
257261

258-
const options = getContextMenuOptions("/v", null, mockQueryItems, [], [], numericCommands)
262+
const options = getContextMenuOptions(t, "/v", null, mockQueryItems, [], [], numericCommands)
259263

260264
const commandNames = options.map((option) => option.value)
261265
expect(commandNames).toContain("v2-setup")

‎webview-ui/src/components/chat/ApiConfigSelector.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,14 @@ export const ApiConfigSelector = ({
207207
"sticky top-0 z-10 bg-vscode-dropdown-background py-1",
208208
unpinnedConfigs.length > 0 && "border-b border-vscode-dropdown-foreground/10",
209209
)}
210-
aria-label="Pinned configurations">
210+
aria-label={t("prompts:apiConfiguration.pinnedGroupAriaLabel")}>
211211
{pinnedConfigs.map((config) => renderConfigItem(config, true))}
212212
</div>
213213
)}
214214

215215
{/* Unpinned configs */}
216216
{unpinnedConfigs.length > 0 && (
217-
<div className="py-1" aria-label="All configurations">
217+
<div className="py-1" aria-label={t("prompts:apiConfiguration.allGroupAriaLabel")}>
218218
{unpinnedConfigs.map((config) => renderConfigItem(config, false))}
219219
</div>
220220
)}

‎webview-ui/src/components/chat/AutoApproveDropdown.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,10 @@ export const AutoApproveDropdown = ({ disabled = false, triggerClassName = "" }:
270270
}}>
271271
<ToggleSwitch
272272
checked={effectiveAutoApprovalEnabled}
273-
aria-label="Toggle auto-approval"
273+
aria-label={t("chat:autoApprove.toggleAriaLabel")}
274274
onChange={handleAutoApprovalToggle}
275275
/>
276-
<span className={cn("text-sm font-bold select-none")}>Enabled</span>
276+
<span className={cn("text-sm font-bold select-none")}>{t("chat:autoApprove.enabled")}</span>
277277
</label>
278278
</div>
279279
</div>

0 commit comments

Comments
 (0)