Skip to content

Commit 045f213

Browse files
committed
feat(i18n): Add new language settings translations
Adds translations for pluginLanguage and commitLanguage to the settings panel for all supported languages. This ensures that the language selection options in the settings view are properly localized, improving the user experience for non-English speakers.
1 parent c112c85 commit 045f213

27 files changed

+92
-7
lines changed

packages/types/src/global-settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export const globalSettingsSchema = z.object({
9090
codebaseIndexConfig: codebaseIndexConfigSchema.optional(),
9191

9292
language: languagesSchema.optional(),
93+
commitLanguage: languagesSchema.optional(),
9394

9495
telemetrySetting: telemetrySettingsSchema.optional(),
9596

src/core/webview/ClineProvider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,7 @@ export class ClineProvider
13981398
telemetrySetting,
13991399
showRooIgnoredFiles,
14001400
language,
1401+
commitLanguage,
14011402
maxReadFileLine,
14021403
terminalCompressProgressBar,
14031404
historyPreviewCollapsed,
@@ -1496,6 +1497,7 @@ export class ClineProvider
14961497
machineId,
14971498
showRooIgnoredFiles: showRooIgnoredFiles ?? true,
14981499
language: language ?? formatLanguage(vscode.env.language),
1500+
commitLanguage: commitLanguage ?? formatLanguage(vscode.env.language),
14991501
renderContext: this.renderContext,
15001502
maxReadFileLine: maxReadFileLine ?? -1,
15011503
maxConcurrentFileReads: maxConcurrentFileReads ?? 5,
@@ -1632,6 +1634,7 @@ export class ClineProvider
16321634
terminalCompressProgressBar: stateValues.terminalCompressProgressBar ?? true,
16331635
mode: stateValues.mode ?? defaultModeSlug,
16341636
language: stateValues.language ?? formatLanguage(vscode.env.language),
1637+
commitLanguage: stateValues.commitLanguage ?? formatLanguage(vscode.env.language),
16351638
mcpEnabled: stateValues.mcpEnabled ?? true,
16361639
enableMcpServerCreation: stateValues.enableMcpServerCreation ?? true,
16371640
alwaysApproveResubmit: stateValues.alwaysApproveResubmit ?? false,

src/core/webview/webviewMessageHandler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,11 @@ export const webviewMessageHandler = async (
11091109
await updateGlobalState("language", message.text as Language)
11101110
await provider.postStateToWebview()
11111111
break
1112+
case "commitLanguage":
1113+
changeLanguage(message.text ?? "en")
1114+
await updateGlobalState("commitLanguage", message.text as Language)
1115+
await provider.postStateToWebview()
1116+
break
11121117
case "showRooIgnoredFiles":
11131118
await updateGlobalState("showRooIgnoredFiles", message.bool ?? true)
11141119
await provider.postStateToWebview()

src/integrations/git/generateCommitMessage.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ async function getChanges(git: SimpleGit, repoPath: string): Promise<string> {
3636
return `${trackedFilesDiff}\n${untrackedFilesContent}`.trim()
3737
}
3838

39-
function createPrompt(diff: string): string {
40-
return `Create a git commit message from the following diff:\n${diff}`
39+
function createPrompt(diff: string, language: string): string {
40+
return `Create a git commit message in ${language} from the following diff:\n${diff}.Remember to print only commit messages text without any extra markdown or content that would require special tools to display. Adhere to best git commit message practices. Remmber to use ${language} in this commit message.`
4141
}
4242

4343
export async function generateCommitMessage(context: vscode.ExtensionContext) {
@@ -68,7 +68,9 @@ export async function generateCommitMessage(context: vscode.ExtensionContext) {
6868
}
6969
const provider = buildApiHandler(providerSettings)
7070
const modelName = provider.getModel().id
71-
const prompt = createPrompt(diff)
71+
const settings = contextProxy.getGlobalSettings()
72+
const commitLanguage = settings.commitLanguage || settings.language || "en"
73+
const prompt = createPrompt(diff, commitLanguage)
7274
const messages: Anthropic.Messages.MessageParam[] = [
7375
{
7476
role: "user",
@@ -92,7 +94,7 @@ export async function generateCommitMessage(context: vscode.ExtensionContext) {
9294
}
9395
}
9496

95-
const finalMessage = commitMessage.replace(/```/g, "").trim()
97+
const finalMessage = commitMessage.trim()
9698
gitApi.repositories[0].inputBox.value = finalMessage
9799
},
98100
)

src/shared/ExtensionMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ export type ExtensionState = Pick<
203203
| "fuzzyMatchThreshold"
204204
// | "experiments" // Optional in GlobalSettings, required here.
205205
| "language"
206+
| "commitLanguage"
206207
// | "telemetrySetting" // Optional in GlobalSettings, required here.
207208
// | "mcpEnabled" // Optional in GlobalSettings, required here.
208209
// | "enableMcpServerCreation" // Optional in GlobalSettings, required here.

src/shared/WebviewMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export interface WebviewMessage {
144144
| "browserConnectionResult"
145145
| "remoteBrowserEnabled"
146146
| "language"
147+
| "commitLanguage"
147148
| "maxReadFileLine"
148149
| "maxConcurrentFileReads"
149150
| "searchFiles"

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,17 @@ import { Section } from "./Section"
1515

1616
type LanguageSettingsProps = HTMLAttributes<HTMLDivElement> & {
1717
language: string
18-
setCachedStateField: SetCachedStateField<"language">
18+
commitLanguage: string
19+
setCachedStateField: SetCachedStateField<"language" | "commitLanguage">
1920
}
2021

21-
export const LanguageSettings = ({ language, setCachedStateField, className, ...props }: LanguageSettingsProps) => {
22+
export const LanguageSettings = ({
23+
language,
24+
commitLanguage,
25+
setCachedStateField,
26+
className,
27+
...props
28+
}: LanguageSettingsProps) => {
2229
const { t } = useAppTranslation()
2330

2431
return (
@@ -31,6 +38,7 @@ export const LanguageSettings = ({ language, setCachedStateField, className, ...
3138
</SectionHeader>
3239

3340
<Section>
41+
<div className="text-sm text-vscode-descriptionForeground">{t("settings:sections.pluginLanguage")}</div>
3442
<Select value={language} onValueChange={(value) => setCachedStateField("language", value as Language)}>
3543
<SelectTrigger className="w-full">
3644
<SelectValue placeholder={t("settings:common.select")} />
@@ -46,6 +54,24 @@ export const LanguageSettings = ({ language, setCachedStateField, className, ...
4654
</SelectGroup>
4755
</SelectContent>
4856
</Select>
57+
<div className="text-sm text-vscode-descriptionForeground">{t("settings:sections.commitLanguage")}</div>
58+
<Select
59+
value={commitLanguage}
60+
onValueChange={(value) => setCachedStateField("commitLanguage", value as Language)}>
61+
<SelectTrigger className="w-full">
62+
<SelectValue placeholder={t("settings:common.select")} />
63+
</SelectTrigger>
64+
<SelectContent>
65+
<SelectGroup>
66+
{Object.entries(LANGUAGES).map(([code, name]) => (
67+
<SelectItem key={code} value={code}>
68+
{name}
69+
<span className="text-muted-foreground">({code})</span>
70+
</SelectItem>
71+
))}
72+
</SelectGroup>
73+
</SelectContent>
74+
</Select>
4975
</Section>
5076
</div>
5177
)

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
125125
allowedCommands,
126126
allowedMaxRequests,
127127
language,
128+
commitLanguage,
128129
alwaysAllowBrowser,
129130
alwaysAllowExecute,
130131
alwaysAllowMcp,
@@ -261,6 +262,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
261262
const handleSubmit = () => {
262263
if (isSettingValid) {
263264
vscode.postMessage({ type: "language", text: language })
265+
vscode.postMessage({ type: "commitLanguage", text: commitLanguage })
264266
vscode.postMessage({ type: "alwaysAllowReadOnly", bool: alwaysAllowReadOnly })
265267
vscode.postMessage({
266268
type: "alwaysAllowReadOnlyOutsideWorkspace",
@@ -694,7 +696,11 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
694696

695697
{/* Language Section */}
696698
{activeTab === "language" && (
697-
<LanguageSettings language={language || "en"} setCachedStateField={setCachedStateField} />
699+
<LanguageSettings
700+
language={language || "en"}
701+
commitLanguage={commitLanguage || "en"}
702+
setCachedStateField={setCachedStateField}
703+
/>
698704
)}
699705

700706
{/* About Section */}

webview-ui/src/context/ExtensionStateContext.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
type ExperimentId,
99
type OrganizationAllowList,
1010
ORGANIZATION_ALLOW_ALL,
11+
type Language,
1112
} from "@roo-code/types"
1213

1314
import { ExtensionMessage, ExtensionState, MarketplaceInstalledMetadata } from "@roo/ExtensionMessage"
@@ -48,6 +49,7 @@ export interface ExtensionStateContextType extends ExtensionState {
4849
marketplaceInstalledMetadata?: MarketplaceInstalledMetadata
4950
profileThresholds: Record<string, number>
5051
setProfileThresholds: (value: Record<string, number>) => void
52+
setCommitLanguage: (value: Language) => void
5153
setApiConfiguration: (config: ProviderSettings) => void
5254
setCustomInstructions: (value?: string) => void
5355
setAlwaysAllowReadOnly: (value: boolean) => void
@@ -164,6 +166,7 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
164166
enableCheckpoints: true,
165167
fuzzyMatchThreshold: 1.0,
166168
language: "en", // Default language code
169+
commitLanguage: "en",
167170
writeDelayMs: 1000,
168171
browserViewportSize: "900x600",
169172
screenshotQuality: 75,
@@ -356,6 +359,7 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
356359
setState((prevState) => ({ ...prevState, experiments: { ...prevState.experiments, [id]: enabled } })),
357360
setApiConfiguration,
358361
setCustomInstructions: (value) => setState((prevState) => ({ ...prevState, customInstructions: value })),
362+
setCommitLanguage: (value) => setState((prevState) => ({ ...prevState, commitLanguage: value })),
359363
setAlwaysAllowReadOnly: (value) => setState((prevState) => ({ ...prevState, alwaysAllowReadOnly: value })),
360364
setAlwaysAllowReadOnlyOutsideWorkspace: (value) =>
361365
setState((prevState) => ({ ...prevState, alwaysAllowReadOnlyOutsideWorkspace: value })),

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
"prompts": "Indicacions",
3232
"experimental": "Experimental",
3333
"language": "Idioma",
34+
"pluginLanguage": "Idioma del connector",
35+
"commitLanguage": "Idioma del commit",
3436
"about": "Sobre Roo Code"
3537
},
3638
"prompts": {

0 commit comments

Comments
 (0)