From 79e1d11b2e43d29160555fff6906ac88c15008e8 Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Sun, 16 Mar 2025 16:49:07 -0400 Subject: [PATCH] Add a language picker --- src/core/webview/ClineProvider.ts | 7 ++- src/exports/roo-code.d.ts | 1 + src/shared/WebviewMessage.ts | 1 + src/shared/globalState.ts | 1 + .../components/settings/SettingsFooter.tsx | 50 ++++++++++++++++++- .../src/components/settings/SettingsView.tsx | 15 +++++- 6 files changed, 71 insertions(+), 4 deletions(-) diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index e3a4f0707e..40b747f0ed 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -1527,6 +1527,10 @@ export class ClineProvider implements vscode.WebviewViewProvider { await this.updateGlobalState("browserToolEnabled", message.bool ?? true) await this.postStateToWebview() break + case "language": + await this.updateGlobalState("language", message.text) + await this.postStateToWebview() + break case "showRooIgnoredFiles": await this.updateGlobalState("showRooIgnoredFiles", message.bool ?? true) await this.postStateToWebview() @@ -2506,8 +2510,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { writeDelayMs: stateValues.writeDelayMs ?? 1000, terminalOutputLineLimit: stateValues.terminalOutputLineLimit ?? 500, mode: stateValues.mode ?? defaultModeSlug, - // Pass the VSCode language code directly - language: formatLanguage(vscode.env.language), + language: stateValues.language || formatLanguage(vscode.env.language), mcpEnabled: stateValues.mcpEnabled ?? true, enableMcpServerCreation: stateValues.enableMcpServerCreation ?? true, alwaysApproveResubmit: stateValues.alwaysApproveResubmit ?? false, diff --git a/src/exports/roo-code.d.ts b/src/exports/roo-code.d.ts index 1c45dec84b..f9764b91a5 100644 --- a/src/exports/roo-code.d.ts +++ b/src/exports/roo-code.d.ts @@ -218,6 +218,7 @@ export type GlobalStateKey = | "telemetrySetting" | "showRooIgnoredFiles" | "remoteBrowserEnabled" + | "language" export type ConfigurationKey = GlobalStateKey | SecretKey diff --git a/src/shared/WebviewMessage.ts b/src/shared/WebviewMessage.ts index bb77ea7203..e802b8d8af 100644 --- a/src/shared/WebviewMessage.ts +++ b/src/shared/WebviewMessage.ts @@ -107,6 +107,7 @@ export interface WebviewMessage { | "discoverBrowser" | "browserConnectionResult" | "remoteBrowserEnabled" + | "language" text?: string disabled?: boolean askResponse?: ClineAskResponse diff --git a/src/shared/globalState.ts b/src/shared/globalState.ts index cec7bdf9ce..c2b78f1ef7 100644 --- a/src/shared/globalState.ts +++ b/src/shared/globalState.ts @@ -116,6 +116,7 @@ export const GLOBAL_STATE_KEYS = [ "telemetrySetting", "showRooIgnoredFiles", "remoteBrowserEnabled", + "language", "maxWorkspaceFiles", ] as const diff --git a/webview-ui/src/components/settings/SettingsFooter.tsx b/webview-ui/src/components/settings/SettingsFooter.tsx index 5106f1e2d2..5c00e35793 100644 --- a/webview-ui/src/components/settings/SettingsFooter.tsx +++ b/webview-ui/src/components/settings/SettingsFooter.tsx @@ -1,23 +1,52 @@ import { HTMLAttributes } from "react" import { useAppTranslation } from "@/i18n/TranslationContext" import { Trans } from "react-i18next" +import { Globe } from "lucide-react" import { VSCodeButton, VSCodeCheckbox, VSCodeLink } from "@vscode/webview-ui-toolkit/react" import { vscode } from "@/utils/vscode" import { cn } from "@/lib/utils" import { TelemetrySetting } from "../../../../src/shared/TelemetrySetting" +import { SetCachedStateField } from "./types" + +// Map of language codes to their display names +const LANGUAGES: Record = { + ar: "العربية", + ca: "Català", + cs: "Čeština", + de: "Deutsch", + en: "English", + es: "Español", + fr: "Français", + hi: "हिन्दी", + hu: "Magyar", + it: "Italiano", + ja: "日本語", + ko: "한국어", + pl: "Polski", + pt: "Português", + "pt-BR": "Português do Brasil", + ru: "Русский", + tr: "Türkçe", + "zh-CN": "简体中文", + "zh-TW": "繁體中文", +} type SettingsFooterProps = HTMLAttributes & { version: string telemetrySetting: TelemetrySetting setTelemetrySetting: (setting: TelemetrySetting) => void + language: string + setCachedStateField: SetCachedStateField<"language"> } export const SettingsFooter = ({ version, telemetrySetting, setTelemetrySetting, + language, + setCachedStateField, className, ...props }: SettingsFooterProps) => { @@ -35,7 +64,26 @@ export const SettingsFooter = ({ }} />

-

{t("settings:footer.version", { version })}

+
+
+

Roo Code

+

v{version}

+
+
+ + +
+
(({ onDone }, const { alwaysAllowReadOnly, allowedCommands, + language, alwaysAllowBrowser, alwaysAllowExecute, alwaysAllowMcp, @@ -175,6 +176,7 @@ const SettingsView = forwardRef(({ onDone }, const handleSubmit = () => { if (isSettingValid) { + vscode.postMessage({ type: "language", text: language }) vscode.postMessage({ type: "alwaysAllowReadOnly", bool: alwaysAllowReadOnly }) vscode.postMessage({ type: "alwaysAllowWrite", bool: alwaysAllowWrite }) vscode.postMessage({ type: "alwaysAllowExecute", bool: alwaysAllowExecute }) @@ -253,7 +255,16 @@ const SettingsView = forwardRef(({ onDone }, { id: "advanced", icon: Cog, ref: advancedRef }, { id: "experimental", icon: FlaskConical, ref: experimentalRef }, ], - [providersRef, autoApproveRef, browserRef, checkpointRef, notificationsRef, advancedRef, experimentalRef], + [ + providersRef, + autoApproveRef, + browserRef, + checkpointRef, + notificationsRef, + contextRef, + advancedRef, + experimentalRef, + ], ) const handleScroll = useCallback((e: React.UIEvent) => { @@ -450,6 +461,8 @@ const SettingsView = forwardRef(({ onDone }, version={version} telemetrySetting={telemetrySetting} setTelemetrySetting={setTelemetrySetting} + language={language || "en"} + setCachedStateField={setCachedStateField} />