Skip to content

Commit a2be45e

Browse files
committed
i18n for chattextarea
1 parent d45275f commit a2be45e

File tree

22 files changed

+177
-53
lines changed

22 files changed

+177
-53
lines changed

.roomodes

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
{
22
"customModes": [
3-
{
4-
"slug": "translate",
5-
"name": "Translate",
6-
"roleDefinition": "You are Roo, a linguistic specialist focused on translating and managing localization files. Your responsibility is to help maintain and update translation files for the application, ensuring consistency and accuracy across all language resources.",
7-
"groups": [
8-
"read",
9-
["edit", { "fileRegex": "src/i18n/locales/", "description": "Translation files only" }]
10-
],
11-
"customInstructions": "When translating content:\n- Maintain consistent terminology across all translations\n- Respect the JSON structure of translation files\n- Consider context when translating UI strings\n- Watch for placeholders (like {{variable}}) and preserve them in translations\n- Be mindful of text length in UI elements when translating to languages that might require more characters\n- If you need context for a translation, use read_file to examine the components using these strings"
12-
},
133
{
144
"slug": "test",
155
"name": "Test",
@@ -18,12 +8,32 @@
188
"read",
199
"browser",
2010
"command",
21-
["edit", {
22-
"fileRegex": "(__tests__/.*|__mocks__/.*|\\.test\\.(ts|tsx|js|jsx)$|/test/.*|jest\\.config\\.(js|ts)$)",
23-
"description": "Test files, mocks, and Jest configuration"
24-
}]
11+
[
12+
"edit",
13+
{
14+
"fileRegex": "(__tests__/.*|__mocks__/.*|\\.test\\.(ts|tsx|js|jsx)$|/test/.*|jest\\.config\\.(js|ts)$)",
15+
"description": "Test files, mocks, and Jest configuration"
16+
}
17+
]
2518
],
2619
"customInstructions": "When writing tests:\n- Always use describe/it blocks for clear test organization\n- Include meaningful test descriptions\n- Use beforeEach/afterEach for proper test isolation\n- Implement proper error cases\n- Add JSDoc comments for complex test scenarios\n- Ensure mocks are properly typed\n- Verify both positive and negative test cases"
20+
},
21+
{
22+
"slug": "translate",
23+
"name": "Translate",
24+
"roleDefinition": "You are Roo, a linguistic specialist focused on translating and managing localization files. Your responsibility is to help maintain and update translation files for the application, ensuring consistency and accuracy across all language resources.",
25+
"customInstructions": "When internationalizing and translating content:\n\n# Translation Style and Tone\n- Maintain a direct and concise style that mirrors the tone of the original text\n- Carefully account for colloquialisms and idiomatic expressions in both source and target languages\n- Aim for culturally relevant and meaningful translations rather than literal translations\n- Adapt the formality level to match the original content (whether formal or informal)\n- Preserve the personality and voice of the original content\n- Use natural-sounding language that feels native to speakers of the target language\n\n# Technical Implementation\n- Use namespaces to organize translations logically\n- Handle pluralization using i18next's built-in capabilities\n- Implement proper interpolation for variables using {{variable}} syntax\n- Don't include defaultValue. The `en` translations are the fallback.\n\n# Quality Assurance\n- Maintain consistent terminology across all translations\n- Respect the JSON structure of translation files\n- Watch for placeholders and preserve them in translations\n- Be mindful of text length in UI elements when translating to languages that might require more characters\n- Use context-aware translations when the same string has different meanings\n\n# Supported Languages\n- Localize all strings into the following locale files: ar, ca, cs, de, en, es, fr, hi, hu, it, ja, ko, pl, pt, pt-BR, ru, tr, zh-CN, zh-TW",
26+
"groups": [
27+
"read",
28+
[
29+
"edit",
30+
{
31+
"fileRegex": "(.*\\.(md|ts|tsx|js|jsx)$|.*\\.json$)",
32+
"description": "Source code, translation files, and documentation"
33+
}
34+
]
35+
],
36+
"source": "project"
2737
}
2838
]
2939
}

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import Thumbnails from "../common/Thumbnails"
2020
import { convertToMentionPath } from "../../utils/path-mentions"
2121
import { MAX_IMAGES_PER_MESSAGE } from "./ChatView"
2222
import ContextMenu from "./ContextMenu"
23+
import { useAppTranslation } from "../../i18n/TranslationContext"
2324

2425
interface ChatTextAreaProps {
2526
inputValue: string
@@ -56,6 +57,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
5657
},
5758
ref,
5859
) => {
60+
const { t } = useAppTranslation()
5961
const { filePaths, openedTabs, currentApiConfigName, listApiConfigMeta, customModes, cwd } = useExtensionState()
6062
const [gitCommits, setGitCommits] = useState<any[]>([])
6163
const [showDropdown, setShowDropdown] = useState(false)
@@ -133,12 +135,11 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
133135
}
134136
vscode.postMessage(message)
135137
} else {
136-
const promptDescription =
137-
"The 'Enhance Prompt' button helps improve your prompt by providing additional context, clarification, or rephrasing. Try typing a prompt in here and clicking the button again to see how it works."
138+
const promptDescription = t("chat:enhancePromptDescription")
138139
setInputValue(promptDescription)
139140
}
140141
}
141-
}, [inputValue, textAreaDisabled, setInputValue])
142+
}, [inputValue, textAreaDisabled, setInputValue, t])
142143

143144
const queryItems = useMemo(() => {
144145
return [
@@ -475,7 +476,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
475476
const reader = new FileReader()
476477
reader.onloadend = () => {
477478
if (reader.error) {
478-
console.error("Error reading file:", reader.error)
479+
console.error(t("chat:errorReadingFile"), reader.error)
479480
resolve(null)
480481
} else {
481482
const result = reader.result
@@ -490,11 +491,11 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
490491
if (dataUrls.length > 0) {
491492
setSelectedImages((prevImages) => [...prevImages, ...dataUrls].slice(0, MAX_IMAGES_PER_MESSAGE))
492493
} else {
493-
console.warn("No valid images were processed")
494+
console.warn(t("chat:noValidImages"))
494495
}
495496
}
496497
},
497-
[shouldDisableImages, setSelectedImages, cursorPosition, setInputValue, inputValue],
498+
[shouldDisableImages, setSelectedImages, cursorPosition, setInputValue, inputValue, t],
498499
)
499500

500501
const handleThumbnailsHeightChange = useCallback((height: number) => {
@@ -611,7 +612,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
611612
const reader = new FileReader()
612613
reader.onloadend = () => {
613614
if (reader.error) {
614-
console.error("Error reading file:", reader.error)
615+
console.error(t("chat:errorReadingFile"), reader.error)
615616
resolve(null)
616617
} else {
617618
const result = reader.result
@@ -634,7 +635,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
634635
})
635636
}
636637
} else {
637-
console.warn("No valid images were processed")
638+
console.warn(t("chat:noValidImages"))
638639
}
639640
}
640641
}}
@@ -779,7 +780,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
779780
<SelectDropdown
780781
value={mode}
781782
disabled={textAreaDisabled}
782-
title="Select mode for interaction"
783+
title={t("chat:selectMode")}
783784
options={[
784785
// Add the shortcut text as a disabled option at the top
785786
{
@@ -797,13 +798,13 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
797798
// Add separator
798799
{
799800
value: "sep-1",
800-
label: "Separator",
801+
label: t("chat:separator"),
801802
type: DropdownOptionType.SEPARATOR,
802803
},
803804
// Add Edit option
804805
{
805806
value: "promptsButtonClicked",
806-
label: "Edit...",
807+
label: t("chat:edit"),
807808
type: DropdownOptionType.ACTION,
808809
},
809810
]}
@@ -829,7 +830,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
829830
<SelectDropdown
830831
value={currentApiConfigName || ""}
831832
disabled={textAreaDisabled}
832-
title="Select API configuration"
833+
title={t("chat:selectApiConfig")}
833834
options={[
834835
// Add all API configurations
835836
...(listApiConfigMeta || []).map((config) => ({
@@ -840,13 +841,13 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
840841
// Add separator
841842
{
842843
value: "sep-2",
843-
label: "Separator",
844+
label: t("chat:separator"),
844845
type: DropdownOptionType.SEPARATOR,
845846
},
846847
// Add Edit option
847848
{
848849
value: "settingsButtonClicked",
849-
label: "Edit...",
850+
label: t("chat:edit"),
850851
type: DropdownOptionType.ACTION,
851852
},
852853
]}
@@ -886,7 +887,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
886887
role="button"
887888
aria-label="enhance prompt"
888889
data-testid="enhance-prompt-button"
889-
title="Enhance prompt with additional context"
890+
title={t("chat:enhancePrompt")}
890891
className={`input-icon-button ${
891892
textAreaDisabled ? "disabled" : ""
892893
} codicon codicon-sparkle`}
@@ -899,13 +900,13 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
899900
className={`input-icon-button ${
900901
shouldDisableImages ? "disabled" : ""
901902
} codicon codicon-device-camera`}
902-
title="Add images to message"
903+
title={t("chat:addImages")}
903904
onClick={() => !shouldDisableImages && onSelectImages()}
904905
style={{ fontSize: 16.5 }}
905906
/>
906907
<span
907908
className={`input-icon-button ${textAreaDisabled ? "disabled" : ""} codicon codicon-send`}
908-
title="Send message"
909+
title={t("chat:sendMessage")}
909910
onClick={() => !textAreaDisabled && onSend()}
910911
style={{ fontSize: 15 }}
911912
/>

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ interface ChatViewProps {
4242
export const MAX_IMAGES_PER_MESSAGE = 20 // Anthropic limits to 20 images
4343

4444
const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0
45-
const modeShortcutText = `${isMac ? "⌘" : "Ctrl"} + . for next mode`
4645

4746
const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryView }: ChatViewProps) => {
47+
const { t } = useAppTranslation()
48+
const modeShortcutText = `${isMac ? "⌘" : "Ctrl"} + . ${t("chat:forNextMode")}`
4849
const {
4950
version,
5051
clineMessages: messages,
@@ -67,8 +68,6 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
6768
telemetrySetting,
6869
} = useExtensionState()
6970

70-
const { t } = useAppTranslation()
71-
7271
//const task = messages.length > 0 ? (messages[0].say === "task" ? messages[0] : undefined) : undefined) : undefined
7372
const task = useMemo(() => messages.at(0), [messages]) // leaving this less safe version here since if the first message is not a task, then the extension is in a bad state and needs to be debugged (see Cline.abort)
7473
const modifiedMessages = useMemo(() => combineApiRequests(combineCommandSequences(messages.slice(1))), [messages])

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,11 @@
5656
"typeTask": "اكتب مهمتك هنا...",
5757
"addContext": "@ لإضافة سياق، / لتبديل الأوضاع",
5858
"dragFiles": "اضغط على shift لسحب الملفات",
59-
"dragFilesImages": "اضغط على shift لسحب الملفات/الصور"
59+
"dragFilesImages": "اضغط على shift لسحب الملفات/الصور",
60+
"enhancePromptDescription": "يساعد زر 'تحسين المطالبة' على تحسين طلبك من خلال توفير سياق إضافي أو توضيحات أو إعادة صياغة. جرب كتابة طلب هنا وانقر على الزر مرة أخرى لمعرفة كيفية عمله.",
61+
"errorReadingFile": "خطأ في قراءة الملف:",
62+
"noValidImages": "لم تتم معالجة أي صور صالحة",
63+
"separator": "فاصل",
64+
"edit": "تعديل...",
65+
"forNextMode": "للوضع التالي"
6066
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,11 @@
5656
"typeTask": "Escriu la teva tasca aquí...",
5757
"addContext": "@ per afegir context, / per canviar de mode",
5858
"dragFiles": "manté premut shift per arrossegar fitxers",
59-
"dragFilesImages": "manté premut shift per arrossegar fitxers/imatges"
59+
"dragFilesImages": "manté premut shift per arrossegar fitxers/imatges",
60+
"enhancePromptDescription": "El botó 'Millora la sol·licitud' ajuda a millorar la teva sol·licitud proporcionant context addicional, aclariments o reformulacions. Prova d'escriure una sol·licitud aquí i fes clic al botó de nou per veure com funciona.",
61+
"errorReadingFile": "Error en llegir el fitxer:",
62+
"noValidImages": "No s'ha processat cap imatge vàlida",
63+
"separator": "Separador",
64+
"edit": "Edita...",
65+
"forNextMode": "per al següent mode"
6066
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,11 @@
5656
"typeTask": "Napište svůj úkol zde...",
5757
"addContext": "@ pro přidání kontextu, / pro přepnutí režimů",
5858
"dragFiles": "podržte shift pro přetažení souborů",
59-
"dragFilesImages": "podržte shift pro přetažení souborů/obrázků"
59+
"dragFilesImages": "podržte shift pro přetažení souborů/obrázků",
60+
"enhancePromptDescription": "Tlačítko 'Vylepšit výzvu' pomáhá zlepšit vaši výzvu poskytnutím dalšího kontextu, objasnění nebo přeformulování. Zkuste zde napsat výzvu a znovu klikněte na tlačítko pro zobrazení, jak to funguje.",
61+
"errorReadingFile": "Chyba při čtení souboru:",
62+
"noValidImages": "Nebyly zpracovány žádné platné obrázky",
63+
"separator": "Oddělovač",
64+
"edit": "Upravit...",
65+
"forNextMode": "pro další režim"
6066
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,11 @@
5656
"typeTask": "Geben Sie hier Ihre Aufgabe ein...",
5757
"addContext": "@ um Kontext hinzuzufügen, / um Modi zu wechseln",
5858
"dragFiles": "Halten Sie die Umschalttaste gedrückt, um Dateien zu ziehen",
59-
"dragFilesImages": "Halten Sie die Umschalttaste gedrückt, um Dateien/Bilder zu ziehen"
59+
"dragFilesImages": "Halten Sie die Umschalttaste gedrückt, um Dateien/Bilder zu ziehen",
60+
"enhancePromptDescription": "Die Schaltfläche 'Eingabeaufforderung verbessern' hilft, Ihre Anfrage durch zusätzlichen Kontext, Klarstellungen oder Umformulierungen zu verbessern. Geben Sie eine Anfrage ein und klicken Sie erneut auf die Schaltfläche, um zu sehen, wie es funktioniert.",
61+
"errorReadingFile": "Fehler beim Lesen der Datei:",
62+
"noValidImages": "Es wurden keine gültigen Bilder verarbeitet",
63+
"separator": "Trennlinie",
64+
"edit": "Bearbeiten...",
65+
"forNextMode": "für nächsten Modus"
6066
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,17 @@
5050
"selectMode": "Select mode for interaction",
5151
"selectApiConfig": "Select API configuration",
5252
"enhancePrompt": "Enhance prompt with additional context",
53+
"enhancePromptDescription": "The 'Enhance Prompt' button helps improve your prompt by providing additional context, clarification, or rephrasing. Try typing a prompt in here and clicking the button again to see how it works.",
5354
"addImages": "Add images to message",
5455
"sendMessage": "Send message",
5556
"typeMessage": "Type a message...",
5657
"typeTask": "Type your task here...",
5758
"addContext": "@ to add context, / to switch modes",
5859
"dragFiles": "hold shift to drag in files",
59-
"dragFilesImages": "hold shift to drag in files/images"
60+
"dragFilesImages": "hold shift to drag in files/images",
61+
"errorReadingFile": "Error reading file:",
62+
"noValidImages": "No valid images were processed",
63+
"separator": "Separator",
64+
"edit": "Edit...",
65+
"forNextMode": "for next mode"
6066
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,11 @@
5656
"typeTask": "Escribe tu tarea aquí...",
5757
"addContext": "@ para agregar contexto, / para cambiar modos",
5858
"dragFiles": "mantén shift para arrastrar archivos",
59-
"dragFilesImages": "mantén shift para arrastrar archivos/imágenes"
59+
"dragFilesImages": "mantén shift para arrastrar archivos/imágenes",
60+
"enhancePromptDescription": "El botón 'Mejorar el mensaje' ayuda a mejorar tu petición proporcionando contexto adicional, aclaraciones o reformulaciones. Intenta escribir una petición aquí y haz clic en el botón nuevamente para ver cómo funciona.",
61+
"errorReadingFile": "Error al leer el archivo:",
62+
"noValidImages": "No se procesaron imágenes válidas",
63+
"separator": "Separador",
64+
"edit": "Editar...",
65+
"forNextMode": "para el siguiente modo"
6066
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,11 @@
5656
"typeTask": "Tapez votre tâche ici...",
5757
"addContext": "@ pour ajouter du contexte, / pour changer de mode",
5858
"dragFiles": "maintenez shift pour glisser des fichiers",
59-
"dragFilesImages": "maintenez shift pour glisser des fichiers/images"
59+
"dragFilesImages": "maintenez shift pour glisser des fichiers/images",
60+
"enhancePromptDescription": "Le bouton 'Améliorer l'invite' aide à améliorer votre demande en fournissant un contexte supplémentaire, des clarifications ou des reformulations. Essayez de taper une demande ici et cliquez à nouveau sur le bouton pour voir comment cela fonctionne.",
61+
"errorReadingFile": "Erreur lors de la lecture du fichier :",
62+
"noValidImages": "Aucune image valide n'a été traitée",
63+
"separator": "Séparateur",
64+
"edit": "Modifier...",
65+
"forNextMode": "pour le mode suivant"
6066
}

0 commit comments

Comments
 (0)