Skip to content

Commit e67ed9c

Browse files
authored
Merge pull request #1708 from RooVetGit/language_settings
Add a language picker
2 parents 1749197 + 79e1d11 commit e67ed9c

File tree

6 files changed

+71
-4
lines changed

6 files changed

+71
-4
lines changed

src/core/webview/ClineProvider.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
15271527
await this.updateGlobalState("browserToolEnabled", message.bool ?? true)
15281528
await this.postStateToWebview()
15291529
break
1530+
case "language":
1531+
await this.updateGlobalState("language", message.text)
1532+
await this.postStateToWebview()
1533+
break
15301534
case "showRooIgnoredFiles":
15311535
await this.updateGlobalState("showRooIgnoredFiles", message.bool ?? true)
15321536
await this.postStateToWebview()
@@ -2506,8 +2510,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
25062510
writeDelayMs: stateValues.writeDelayMs ?? 1000,
25072511
terminalOutputLineLimit: stateValues.terminalOutputLineLimit ?? 500,
25082512
mode: stateValues.mode ?? defaultModeSlug,
2509-
// Pass the VSCode language code directly
2510-
language: formatLanguage(vscode.env.language),
2513+
language: stateValues.language || formatLanguage(vscode.env.language),
25112514
mcpEnabled: stateValues.mcpEnabled ?? true,
25122515
enableMcpServerCreation: stateValues.enableMcpServerCreation ?? true,
25132516
alwaysApproveResubmit: stateValues.alwaysApproveResubmit ?? false,

src/exports/roo-code.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ export type GlobalStateKey =
218218
| "telemetrySetting"
219219
| "showRooIgnoredFiles"
220220
| "remoteBrowserEnabled"
221+
| "language"
221222

222223
export type ConfigurationKey = GlobalStateKey | SecretKey
223224

src/shared/WebviewMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export interface WebviewMessage {
107107
| "discoverBrowser"
108108
| "browserConnectionResult"
109109
| "remoteBrowserEnabled"
110+
| "language"
110111
text?: string
111112
disabled?: boolean
112113
askResponse?: ClineAskResponse

src/shared/globalState.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ export const GLOBAL_STATE_KEYS = [
116116
"telemetrySetting",
117117
"showRooIgnoredFiles",
118118
"remoteBrowserEnabled",
119+
"language",
119120
"maxWorkspaceFiles",
120121
] as const
121122

webview-ui/src/components/settings/SettingsFooter.tsx

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,52 @@
11
import { HTMLAttributes } from "react"
22
import { useAppTranslation } from "@/i18n/TranslationContext"
33
import { Trans } from "react-i18next"
4+
import { Globe } from "lucide-react"
45

56
import { VSCodeButton, VSCodeCheckbox, VSCodeLink } from "@vscode/webview-ui-toolkit/react"
67

78
import { vscode } from "@/utils/vscode"
89
import { cn } from "@/lib/utils"
910
import { TelemetrySetting } from "../../../../src/shared/TelemetrySetting"
11+
import { SetCachedStateField } from "./types"
12+
13+
// Map of language codes to their display names
14+
const LANGUAGES: Record<string, string> = {
15+
ar: "العربية",
16+
ca: "Català",
17+
cs: "Čeština",
18+
de: "Deutsch",
19+
en: "English",
20+
es: "Español",
21+
fr: "Français",
22+
hi: "हिन्दी",
23+
hu: "Magyar",
24+
it: "Italiano",
25+
ja: "日本語",
26+
ko: "한국어",
27+
pl: "Polski",
28+
pt: "Português",
29+
"pt-BR": "Português do Brasil",
30+
ru: "Русский",
31+
tr: "Türkçe",
32+
"zh-CN": "简体中文",
33+
"zh-TW": "繁體中文",
34+
}
1035

1136
type SettingsFooterProps = HTMLAttributes<HTMLDivElement> & {
1237
version: string
1338
telemetrySetting: TelemetrySetting
1439
setTelemetrySetting: (setting: TelemetrySetting) => void
40+
language: string
41+
setCachedStateField: SetCachedStateField<"language">
1542
}
1643

1744
export const SettingsFooter = ({
1845
version,
1946
telemetrySetting,
2047
setTelemetrySetting,
48+
language,
49+
setCachedStateField,
2150
className,
2251
...props
2352
}: SettingsFooterProps) => {
@@ -35,7 +64,26 @@ export const SettingsFooter = ({
3564
}}
3665
/>
3766
</p>
38-
<p className="italic">{t("settings:footer.version", { version })}</p>
67+
<div className="flex items-center gap-4">
68+
<div className="flex items-center text-nowrap">
69+
<p>Roo Code</p>
70+
<p className="italic ml-1">v{version}</p>
71+
</div>
72+
<div className="relative flex items-center">
73+
<Globe className="w-4 h-4 text-vscode-descriptionForeground absolute left-2 pointer-events-none" />
74+
<select
75+
value={language}
76+
onChange={(e) => setCachedStateField("language", e.target.value)}
77+
className="appearance-none bg-transparent text-vscode-foreground border border-transparent hover:border-vscode-input-border focus:border-vscode-focusBorder rounded px-2 py-1 pl-7 text-xs min-w-[70px]"
78+
title={LANGUAGES[language]}>
79+
{Object.entries(LANGUAGES).map(([code, name]) => (
80+
<option key={code} value={code}>
81+
{name}
82+
</option>
83+
))}
84+
</select>
85+
</div>
86+
</div>
3987
<div className="mt-4 mb-4">
4088
<div>
4189
<VSCodeCheckbox

webview-ui/src/components/settings/SettingsView.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone },
7272
const {
7373
alwaysAllowReadOnly,
7474
allowedCommands,
75+
language,
7576
alwaysAllowBrowser,
7677
alwaysAllowExecute,
7778
alwaysAllowMcp,
@@ -175,6 +176,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone },
175176

176177
const handleSubmit = () => {
177178
if (isSettingValid) {
179+
vscode.postMessage({ type: "language", text: language })
178180
vscode.postMessage({ type: "alwaysAllowReadOnly", bool: alwaysAllowReadOnly })
179181
vscode.postMessage({ type: "alwaysAllowWrite", bool: alwaysAllowWrite })
180182
vscode.postMessage({ type: "alwaysAllowExecute", bool: alwaysAllowExecute })
@@ -253,7 +255,16 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone },
253255
{ id: "advanced", icon: Cog, ref: advancedRef },
254256
{ id: "experimental", icon: FlaskConical, ref: experimentalRef },
255257
],
256-
[providersRef, autoApproveRef, browserRef, checkpointRef, notificationsRef, advancedRef, experimentalRef],
258+
[
259+
providersRef,
260+
autoApproveRef,
261+
browserRef,
262+
checkpointRef,
263+
notificationsRef,
264+
contextRef,
265+
advancedRef,
266+
experimentalRef,
267+
],
257268
)
258269

259270
const handleScroll = useCallback((e: React.UIEvent<HTMLDivElement>) => {
@@ -450,6 +461,8 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone },
450461
version={version}
451462
telemetrySetting={telemetrySetting}
452463
setTelemetrySetting={setTelemetrySetting}
464+
language={language || "en"}
465+
setCachedStateField={setCachedStateField}
453466
/>
454467
</TabContent>
455468

0 commit comments

Comments
 (0)