Skip to content

Commit 06c8cb8

Browse files
committed
fix: replace hardcoded aria-labels with i18n translation keys
- Replace hardcoded aria-labels in CommandExecution and CommandPatternSelector components - Add missing translation keys for aria-labels in all locale files - Update tests to use translation keys instead of hardcoded strings - Fix duplicate commandExecution sections in Italian translation file
1 parent ded11f8 commit 06c8cb8

File tree

21 files changed

+210
-325
lines changed

21 files changed

+210
-325
lines changed

webview-ui/src/components/chat/CommandExecution.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec
211211
onClick={() =>
212212
vscode.postMessage({ type: "terminalOperation", terminalOperation: "abort" })
213213
}
214-
aria-label="Abort command execution">
214+
aria-label={t("chat:commandExecution.abortCommand")}>
215215
<Skull className="size-3.5" />
216216
</Button>
217217
</div>
@@ -238,7 +238,11 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec
238238
size="icon"
239239
className="hover:bg-vscode-toolbar-hoverBackground p-0.5"
240240
onClick={() => setIsOutputExpanded(!isOutputExpanded)}
241-
aria-label={isOutputExpanded ? "Collapse output" : "Expand output"}
241+
aria-label={
242+
isOutputExpanded
243+
? t("chat:commandExecution.collapseOutput")
244+
: t("chat:commandExecution.expandOutput")
245+
}
242246
aria-expanded={isOutputExpanded}>
243247
<ChevronDown
244248
className={cn("size-3.5 transition-transform duration-200", {

webview-ui/src/components/chat/CommandPatternSelector.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ export const CommandPatternSelector = ({
5454
<button
5555
onClick={() => setIsExpanded(!isExpanded)}
5656
className="flex items-center gap-2 w-full px-3 py-2 text-xs text-vscode-descriptionForeground hover:text-vscode-foreground hover:bg-vscode-list-hoverBackground transition-all"
57-
aria-label={isExpanded ? "Collapse command management section" : "Expand command management section"}
57+
aria-label={
58+
isExpanded
59+
? t("chat:commandExecution.collapseManagement")
60+
: t("chat:commandExecution.expandManagement")
61+
}
5862
aria-expanded={isExpanded}>
5963
<ChevronDown
6064
className={cn("size-3 transition-transform duration-200", {
@@ -127,8 +131,8 @@ export const CommandPatternSelector = ({
127131
)}
128132
aria-label={
129133
status === "allowed"
130-
? `Remove ${item.pattern} from allowed list`
131-
: `Add ${item.pattern} to allowed list`
134+
? t("chat:commandExecution.removeFromAllowed")
135+
: t("chat:commandExecution.addToAllowed")
132136
}>
133137
<Check className="size-3.5" />
134138
</button>
@@ -149,8 +153,8 @@ export const CommandPatternSelector = ({
149153
)}
150154
aria-label={
151155
status === "denied"
152-
? `Remove ${item.pattern} from denied list`
153-
: `Add ${item.pattern} to denied list`
156+
? t("chat:commandExecution.removeFromDenied")
157+
: t("chat:commandExecution.addToDenied")
154158
}>
155159
<X className="size-3.5" />
156160
</button>

webview-ui/src/components/chat/__tests__/CommandExecution.spec.tsx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ vi.mock("react-i18next", () => ({
1717
useTranslation: () => ({
1818
t: (key: string) => {
1919
// Return the actual translated text for the test
20-
if (key === "chat:commandExecution.manageCommands") {
21-
return "Manage Command Permissions"
20+
const translations: Record<string, string> = {
21+
"chat:commandExecution.manageCommands": "Manage Command Permissions",
22+
"chat:commandExecution.addToAllowed": "Add to allowed list",
23+
"chat:commandExecution.removeFromAllowed": "Remove from allowed list",
24+
"chat:commandExecution.addToDenied": "Add to denied list",
25+
"chat:commandExecution.removeFromDenied": "Remove from denied list",
2226
}
23-
return key
27+
return translations[key] || key
2428
},
2529
}),
2630
Trans: ({ i18nKey, _components }: any) => {
@@ -41,10 +45,14 @@ vi.mock("@src/i18n/TranslationContext", () => ({
4145
useAppTranslation: () => ({
4246
t: (key: string) => {
4347
// Return the actual translated text for the test
44-
if (key === "chat:commandExecution.manageCommands") {
45-
return "Manage Command Permissions"
48+
const translations: Record<string, string> = {
49+
"chat:commandExecution.manageCommands": "Manage Command Permissions",
50+
"chat:commandExecution.addToAllowed": "Add to allowed list",
51+
"chat:commandExecution.removeFromAllowed": "Remove from allowed list",
52+
"chat:commandExecution.addToDenied": "Add to denied list",
53+
"chat:commandExecution.removeFromDenied": "Remove from denied list",
4654
}
47-
return key
55+
return translations[key] || key
4856
},
4957
}),
5058
}))
@@ -181,8 +189,8 @@ describe("CommandExecution", () => {
181189
fireEvent.click(sectionHeader)
182190

183191
// Find and click the allow button for the first suggestion
184-
const allowButton = screen.getByLabelText('Add git commit -m "Initial commit" to allowed list')
185-
fireEvent.click(allowButton)
192+
const allowButtons = screen.getAllByLabelText("Add to allowed list")
193+
fireEvent.click(allowButtons[0]) // Click the first one
186194

187195
await waitFor(() => {
188196
expect(mockPostMessage).toHaveBeenCalledWith({
@@ -221,8 +229,8 @@ describe("CommandExecution", () => {
221229
fireEvent.click(sectionHeader)
222230

223231
// Find and click the allow button for the first suggestion (which should remove it since it's already allowed)
224-
const removeButton = screen.getByLabelText('Remove git commit -m "Initial commit" from allowed list')
225-
fireEvent.click(removeButton)
232+
const removeButtons = screen.getAllByLabelText("Remove from allowed list")
233+
fireEvent.click(removeButtons[0]) // Click the first one
226234

227235
await waitFor(() => {
228236
expect(mockPostMessage).toHaveBeenCalledWith({
@@ -375,8 +383,8 @@ describe("CommandExecution", () => {
375383
fireEvent.click(sectionHeader)
376384

377385
// Find and click the allow button for the first suggestion
378-
const allowButton = screen.getByLabelText("Add git status --short to allowed list")
379-
fireEvent.click(allowButton)
386+
const allowButtons = screen.getAllByLabelText("Add to allowed list")
387+
fireEvent.click(allowButtons[0]) // Click the first one
380388

381389
await waitFor(() => {
382390
expect(mockPostMessage).toHaveBeenCalledWith({

webview-ui/src/i18n/locales/ca/chat.json

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
"wantsToViewTopLevel": "Roo vol veure els fitxers de nivell superior en aquest directori:",
177177
"didViewTopLevel": "Roo ha vist els fitxers de nivell superior en aquest directori:",
178178
"wantsToViewRecursive": "Roo vol veure recursivament tots els fitxers en aquest directori:",
179-
"didViewRecursive": "Roo ha vist recursivament tots els fitxers en aquest directori:",
179+
"didViewRecursive": "Roo ha vist recursivament tots els fitxers en acest directori:",
180180
"wantsToViewDefinitions": "Roo vol veure noms de definicions de codi font utilitzats en aquest directori:",
181181
"didViewDefinitions": "Roo ha vist noms de definicions de codi font utilitzats en aquest directori:",
182182
"wantsToSearch": "Roo vol cercar en aquest directori <code>{{regex}}</code>:",
@@ -185,23 +185,28 @@
185185
"didSearchOutsideWorkspace": "Roo ha cercat en aquest directori (fora de l'espai de treball) <code>{{regex}}</code>:",
186186
"wantsToViewTopLevelOutsideWorkspace": "Roo vol veure els fitxers de nivell superior en aquest directori (fora de l'espai de treball):",
187187
"didViewTopLevelOutsideWorkspace": "Roo ha vist els fitxers de nivell superior en aquest directori (fora de l'espai de treball):",
188-
"wantsToViewRecursiveOutsideWorkspace": "Roo vol veure recursivament tots els fitxers en aquest directori (fora de l'espai de treball):",
189-
"didViewRecursiveOutsideWorkspace": "Roo ha vist recursivament tots els fitxers en aquest directori (fora de l'espai de treball):",
188+
"wantsToViewRecursiveOutsideWorkspace": "Roo vol veure recursivament tots els fitxers en acest directori (fora de l'espai de treball):",
189+
"didViewRecursiveOutsideWorkspace": "Roo ha vist recursivament tots els fitxers en acest directori (fora de l'espai de treball):",
190190
"wantsToViewDefinitionsOutsideWorkspace": "Roo vol veure noms de definicions de codi font utilitzats en aquest directori (fora de l'espai de treball):",
191-
"didViewDefinitionsOutsideWorkspace": "Roo ha vist noms de definicions de codi font utilitzats en aquest directori (fora de l'espai de treball):"
191+
"didViewDefinitionsOutsideWorkspace": "Roo ha vist noms de definicions de codi font utilitzats en acest directori (fora de l'espai de treball):"
192192
},
193193
"commandExecution": {
194194
"whitelistSuggestions": "Suggested patterns to whitelist for automatic approval:",
195-
"running": "Running",
195+
"running": "En execució",
196196
"pid": "PID: {{pid}}",
197-
"exited": "Exited ({{exitCode}})",
198-
"addToAllowedCommands": "Add to Allowed Auto-Execute Commands",
197+
"exited": "Finalitzat ({{exitCode}})",
198+
"addToAllowedCommands": "Afegeix a les ordres d'execució automàtica permeses",
199199
"manageCommands": "Gestiona els permisos de les ordres",
200200
"commandManagementDescription": "Gestiona els permisos de les ordres: Fes clic a ✓ per permetre l'execució automàtica, ✗ per denegar l'execució. Els patrons es poden activar/desactivar o eliminar de les llistes. <settingsLink>Veure totes les opcions</settingsLink>",
201201
"addToAllowed": "Afegeix a la llista permesa",
202202
"removeFromAllowed": "Elimina de la llista permesa",
203203
"addToDenied": "Afegeix a la llista denegada",
204-
"removeFromDenied": "Elimina de la llista denegada"
204+
"removeFromDenied": "Elimina de la llista denegada",
205+
"abortCommand": "Interrompre l'execució de l'ordre",
206+
"expandOutput": "Amplia la sortida",
207+
"collapseOutput": "Redueix la sortida",
208+
"expandManagement": "Amplia la secció de gestió d'ordres",
209+
"collapseManagement": "Redueix la secció de gestió d'ordres"
205210
},
206211
"commandOutput": "Sortida de l'ordre",
207212
"response": "Resposta",
@@ -302,7 +307,7 @@
302307
},
303308
"ask": {
304309
"autoApprovedRequestLimitReached": {
305-
"title": "S'ha arribat al límit de sol·licituds aprovades automàticament",
310+
"title": "S'ha arribat al límit de sol·licituds aprovades automàticamente",
306311
"description": "Roo ha arribat al límit aprovat automàticament de {{count}} sol·licitud(s) d'API. Vols reiniciar el comptador i continuar amb la tasca?",
307312
"button": "Reiniciar i continuar"
308313
}
@@ -331,18 +336,5 @@
331336
},
332337
"versionIndicator": {
333338
"ariaLabel": "Versió {{version}} - Feu clic per veure les notes de llançament"
334-
},
335-
"commandExecution": {
336-
"whitelistSuggestions": "Suggested patterns to whitelist for automatic approval:",
337-
"running": "Running",
338-
"pid": "PID: {{pid}}",
339-
"exited": "Exited ({{exitCode}})",
340-
"addToAllowedCommands": "Add to Allowed Auto-Execute Commands",
341-
"manageCommands": "Gestiona els permisos de les ordres",
342-
"commandManagementDescription": "Gestiona els permisos de les ordres: Fes clic a ✓ per permetre l'execució automàtica, ✗ per denegar l'execució. Els patrons es poden activar/desactivar o eliminar de les llistes. <settingsLink>Veure totes les opcions</settingsLink>",
343-
"addToAllowed": "Afegeix a la llista permesa",
344-
"removeFromAllowed": "Elimina de la llista permesa",
345-
"addToDenied": "Afegeix a la llista denegada",
346-
"removeFromDenied": "Elimina de la llista denegada"
347339
}
348340
}

webview-ui/src/i18n/locales/de/chat.json

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,22 @@
191191
"didViewDefinitionsOutsideWorkspace": "Roo hat Quellcode-Definitionsnamen in diesem Verzeichnis (außerhalb des Arbeitsbereichs) angezeigt:"
192192
},
193193
"commandExecution": {
194-
"whitelistSuggestions": "Suggested patterns to whitelist for automatic approval:",
195-
"running": "Running",
194+
"whitelistSuggestions": "Vorgeschlagene Muster zur Freigabe für die automatische Genehmigung:",
195+
"running": "Wird ausgeführt",
196196
"pid": "PID: {{pid}}",
197-
"exited": "Exited ({{exitCode}})",
198-
"addToAllowedCommands": "Add to Allowed Auto-Execute Commands",
197+
"exited": "Beendet ({{exitCode}})",
198+
"addToAllowedCommands": "Zu den erlaubten automatisch auszuführenden Befehlen hinzufügen",
199199
"manageCommands": "Befehlsberechtigungen verwalten",
200200
"commandManagementDescription": "Befehlsberechtigungen verwalten: Klicke auf ✓, um die automatische Ausführung zu erlauben, ✗, um die Ausführung zu verweigern. Muster können in Listen ein- und ausgeschaltet oder entfernt werden. <settingsLink>Alle Einstellungen anzeigen</settingsLink>",
201201
"addToAllowed": "Zur erlaubten Liste hinzufügen",
202202
"removeFromAllowed": "Von erlaubter Liste entfernen",
203203
"addToDenied": "Zur verweigerten Liste hinzufügen",
204-
"removeFromDenied": "Von verweigerter Liste entfernen"
204+
"removeFromDenied": "Von verweigerter Liste entfernen",
205+
"abortCommand": "Befehlsausführung abbrechen",
206+
"expandOutput": "Ausgabe erweitern",
207+
"collapseOutput": "Ausgabe ausblenden",
208+
"expandManagement": "Befehlsverwaltungs-Abschnitt erweitern",
209+
"collapseManagement": "Befehlsverwaltungs-Abschnitt ausblenden"
205210
},
206211
"commandOutput": "Befehlsausgabe",
207212
"response": "Antwort",
@@ -331,18 +336,5 @@
331336
},
332337
"versionIndicator": {
333338
"ariaLabel": "Version {{version}} - Klicken Sie, um die Versionshinweise anzuzeigen"
334-
},
335-
"commandExecution": {
336-
"whitelistSuggestions": "Suggested patterns to whitelist for automatic approval:",
337-
"running": "Running",
338-
"pid": "PID: {{pid}}",
339-
"exited": "Exited ({{exitCode}})",
340-
"addToAllowedCommands": "Add to Allowed Auto-Execute Commands",
341-
"manageCommands": "Befehlsberechtigungen verwalten",
342-
"commandManagementDescription": "Befehlsberechtigungen verwalten: Klicke auf ✓, um die automatische Ausführung zu erlauben, ✗, um die Ausführung zu verweigern. Muster können in Listen ein- und ausgeschaltet oder entfernt werden. <settingsLink>Alle Einstellungen anzeigen</settingsLink>",
343-
"addToAllowed": "Zur erlaubten Liste hinzufügen",
344-
"removeFromAllowed": "Von erlaubter Liste entfernen",
345-
"addToDenied": "Zur verweigerten Liste hinzufügen",
346-
"removeFromDenied": "Von verweigerter Liste entfernen"
347339
}
348340
}

webview-ui/src/i18n/locales/en/chat.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,12 @@
217217
"addToAllowed": "Add to allowed list",
218218
"removeFromAllowed": "Remove from allowed list",
219219
"addToDenied": "Add to denied list",
220-
"removeFromDenied": "Remove from denied list"
220+
"removeFromDenied": "Remove from denied list",
221+
"abortCommand": "Abort command execution",
222+
"expandOutput": "Expand output",
223+
"collapseOutput": "Collapse output",
224+
"expandManagement": "Expand command management section",
225+
"collapseManagement": "Collapse command management section"
221226
},
222227
"commandOutput": "Command Output",
223228
"response": "Response",

webview-ui/src/i18n/locales/es/chat.json

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,22 @@
191191
"didViewDefinitionsOutsideWorkspace": "Roo vio nombres de definiciones de código fuente utilizados en este directorio (fuera del espacio de trabajo):"
192192
},
193193
"commandExecution": {
194-
"whitelistSuggestions": "Suggested patterns to whitelist for automatic approval:",
195-
"running": "Running",
194+
"whitelistSuggestions": "Patrones sugeridos para incluir en la lista blanca para aprobación automática:",
195+
"running": "Ejecutando",
196196
"pid": "PID: {{pid}}",
197-
"exited": "Exited ({{exitCode}})",
198-
"addToAllowedCommands": "Add to Allowed Auto-Execute Commands",
197+
"exited": "Finalizado ({{exitCode}})",
198+
"addToAllowedCommands": "Añadir a los comandos de ejecución automática permitidos",
199199
"manageCommands": "Administrar permisos de comandos",
200200
"commandManagementDescription": "Administrar permisos de comandos: Haz clic en ✓ para permitir la ejecución automática, ✗ para denegar la ejecución. Los patrones se pueden activar/desactivar o eliminar de las listas. <settingsLink>Ver todos los ajustes</settingsLink>",
201201
"addToAllowed": "Añadir a la lista de permitidos",
202202
"removeFromAllowed": "Eliminar de la lista de permitidos",
203203
"addToDenied": "Añadir a la lista de denegados",
204-
"removeFromDenied": "Eliminar de la lista de denegados"
204+
"removeFromDenied": "Eliminar de la lista de denegados",
205+
"abortCommand": "Abortar la ejecución del comando",
206+
"expandOutput": "Expandir salida",
207+
"collapseOutput": "Contraer salida",
208+
"expandManagement": "Expandir la sección de administración de comandos",
209+
"collapseManagement": "Contraer la sección de administración de comandos"
205210
},
206211
"commandOutput": "Salida del comando",
207212
"response": "Respuesta",
@@ -331,18 +336,5 @@
331336
},
332337
"versionIndicator": {
333338
"ariaLabel": "Versión {{version}} - Haz clic para ver las notas de la versión"
334-
},
335-
"commandExecution": {
336-
"whitelistSuggestions": "Suggested patterns to whitelist for automatic approval:",
337-
"running": "Running",
338-
"pid": "PID: {{pid}}",
339-
"exited": "Exited ({{exitCode}})",
340-
"addToAllowedCommands": "Add to Allowed Auto-Execute Commands",
341-
"manageCommands": "Administrar permisos de comandos",
342-
"commandManagementDescription": "Administrar permisos de comandos: Haz clic en ✓ para permitir la ejecución automática, ✗ para denegar la ejecución. Los patrones se pueden activar/desactivar o eliminar de las listas. <settingsLink>Ver todos los ajustes</settingsLink>",
343-
"addToAllowed": "Añadir a la lista de permitidos",
344-
"removeFromAllowed": "Eliminar de la lista de permitidos",
345-
"addToDenied": "Añadir a la lista de denegados",
346-
"removeFromDenied": "Eliminar de la lista de denegados"
347339
}
348340
}

webview-ui/src/i18n/locales/fr/chat.json

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,22 @@
191191
"didViewDefinitionsOutsideWorkspace": "Roo a vu les noms de définitions de code source utilisés dans ce répertoire (hors espace de travail) :"
192192
},
193193
"commandExecution": {
194-
"whitelistSuggestions": "Suggested patterns to whitelist for automatic approval:",
195-
"running": "Running",
194+
"whitelistSuggestions": "Modèles suggérés à ajouter à la liste blanche pour approbation automatique:",
195+
"running": "En cours d'exécution",
196196
"pid": "PID: {{pid}}",
197-
"exited": "Exited ({{exitCode}})",
198-
"addToAllowedCommands": "Add to Allowed Auto-Execute Commands",
197+
"exited": "Terminé ({{exitCode}})",
198+
"addToAllowedCommands": "Ajouter aux commandes d'exécution automatique autorisées",
199199
"manageCommands": "Gérer les autorisations de commande",
200200
"commandManagementDescription": "Gérer les autorisations de commande : Cliquez sur ✓ pour autoriser l'exécution automatique, ✗ pour refuser l'exécution. Les modèles peuvent être activés/désactivés ou supprimés des listes. <settingsLink>Voir tous les paramètres</settingsLink>",
201201
"addToAllowed": "Ajouter à la liste autorisée",
202202
"removeFromAllowed": "Retirer de la liste autorisée",
203203
"addToDenied": "Ajouter à la liste refusée",
204-
"removeFromDenied": "Retirer de la liste refusée"
204+
"removeFromDenied": "Retirer de la liste refusée",
205+
"abortCommand": "Abandonner l'exécution de la commande",
206+
"expandOutput": "Développer la sortie",
207+
"collapseOutput": "Réduire la sortie",
208+
"expandManagement": "Développer la section de gestion des commandes",
209+
"collapseManagement": "Réduire la section de gestion des commandes"
205210
},
206211
"commandOutput": "Sortie de commande",
207212
"response": "Réponse",
@@ -331,18 +336,5 @@
331336
},
332337
"versionIndicator": {
333338
"ariaLabel": "Version {{version}} - Cliquez pour voir les notes de version"
334-
},
335-
"commandExecution": {
336-
"whitelistSuggestions": "Suggested patterns to whitelist for automatic approval:",
337-
"running": "Running",
338-
"pid": "PID: {{pid}}",
339-
"exited": "Exited ({{exitCode}})",
340-
"addToAllowedCommands": "Add to Allowed Auto-Execute Commands",
341-
"manageCommands": "Gérer les autorisations de commande",
342-
"commandManagementDescription": "Gérer les autorisations de commande : Cliquez sur ✓ pour autoriser l'exécution automatique, ✗ pour refuser l'exécution. Les modèles peuvent être activés/désactivés ou supprimés des listes. <settingsLink>Voir tous les paramètres</settingsLink>",
343-
"addToAllowed": "Ajouter à la liste autorisée",
344-
"removeFromAllowed": "Retirer de la liste autorisée",
345-
"addToDenied": "Ajouter à la liste refusée",
346-
"removeFromDenied": "Retirer de la liste refusée"
347339
}
348340
}

0 commit comments

Comments
 (0)