Skip to content

Commit 00bf914

Browse files
committed
Add i18n
1 parent baa346d commit 00bf914

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+603
-386
lines changed

.roomodes

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"customModes": [
3+
{
4+
"slug": "translator",
5+
"name": "Translator",
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+
},
13+
{
14+
"slug": "test",
15+
"name": "Test",
16+
"roleDefinition": "You are Roo, a Jest testing specialist with deep expertise in:\n- Writing and maintaining Jest test suites\n- Test-driven development (TDD) practices\n- Mocking and stubbing with Jest\n- Integration testing strategies\n- TypeScript testing patterns\n- Code coverage analysis\n- Test performance optimization\n\nYour focus is on maintaining high test quality and coverage across the codebase, working primarily with:\n- Test files in __tests__ directories\n- Mock implementations in __mocks__\n- Test utilities and helpers\n- Jest configuration and setup\n\nYou ensure tests are:\n- Well-structured and maintainable\n- Following Jest best practices\n- Properly typed with TypeScript\n- Providing meaningful coverage\n- Using appropriate mocking strategies",
17+
"groups": [
18+
"read",
19+
"browser",
20+
"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+
}]
25+
],
26+
"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"
27+
}
28+
]
29+
}

src/core/Cline.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import { truncateConversationIfNeeded } from "./sliding-window"
7070
import { ClineProvider } from "./webview/ClineProvider"
7171
import { detectCodeOmission } from "../integrations/editor/detect-omission"
7272
import { BrowserSession } from "../services/browser/BrowserSession"
73+
import { formatLanguage } from "../shared/language"
7374
import { McpHub } from "../services/mcp/McpHub"
7475
import crypto from "crypto"
7576
import { insertGroups } from "./diff/insert-groups"
@@ -3668,7 +3669,7 @@ export class Cline {
36683669
const modeDetails = await getFullModeDetails(currentMode, customModes, customModePrompts, {
36693670
cwd,
36703671
globalCustomInstructions,
3671-
vscodeLanguage: vscode.env.language,
3672+
language: formatLanguage(vscode.env.language),
36723673
})
36733674
details += `\n\n# Current Mode\n`
36743675
details += `<slug>${currentMode}</slug>\n`

src/core/prompts/__tests__/sections.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe("addCustomInstructions", () => {
99
"global instructions",
1010
"/test/path",
1111
"test-mode",
12-
{ vscodeLanguage: "fr" },
12+
{ language: "fr" },
1313
)
1414

1515
expect(result).toContain("Language Preference:")

src/core/prompts/__tests__/system.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ __setMockImplementation(
3737
globalCustomInstructions: string,
3838
cwd: string,
3939
mode: string,
40-
options?: { vscodeLanguage?: string },
40+
options?: { language?: string },
4141
) => {
4242
const sections = []
4343

4444
// Add language preference if provided
45-
if (options?.vscodeLanguage) {
45+
if (options?.language) {
4646
sections.push(
47-
`Language Preference:\nYou should always speak and think in the "${options.vscodeLanguage}" language.`,
47+
`Language Preference:\nYou should always speak and think in the "${options.language}" language.`,
4848
)
4949
}
5050

@@ -792,7 +792,7 @@ describe("addCustomInstructions", () => {
792792

793793
it("should include preferred language when provided", async () => {
794794
const instructions = await addCustomInstructions("", "", "/test/path", defaultModeSlug, {
795-
vscodeLanguage: "es",
795+
language: "es",
796796
})
797797
expect(instructions).toMatchSnapshot()
798798
})
@@ -808,7 +808,7 @@ describe("addCustomInstructions", () => {
808808
"",
809809
"/test/path",
810810
defaultModeSlug,
811-
{ vscodeLanguage: "fr" },
811+
{ language: "fr" },
812812
)
813813
expect(instructions).toMatchSnapshot()
814814
})

src/core/prompts/sections/__tests__/custom-instructions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe("addCustomInstructions", () => {
113113
"global instructions",
114114
"/fake/path",
115115
"test-mode",
116-
{ vscodeLanguage: "es" },
116+
{ language: "es" },
117117
)
118118

119119
expect(result).toContain("Language Preference:")

src/core/prompts/sections/custom-instructions.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export async function addCustomInstructions(
3434
globalCustomInstructions: string,
3535
cwd: string,
3636
mode: string,
37-
options: { vscodeLanguage?: string; rooIgnoreInstructions?: string } = {},
37+
options: { language?: string; rooIgnoreInstructions?: string } = {},
3838
): Promise<string> {
3939
const sections = []
4040

@@ -46,10 +46,8 @@ export async function addCustomInstructions(
4646
}
4747

4848
// Add language preference if provided
49-
if (options.vscodeLanguage) {
50-
sections.push(
51-
`Language Preference:\nYou should always speak and think in the "${options.vscodeLanguage}" language.`,
52-
)
49+
if (options.language) {
50+
sections.push(`Language Preference:\nYou should always speak and think in the "${options.language}" language.`)
5351
}
5452

5553
// Add global instructions first

src/core/prompts/system.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
addCustomInstructions,
2626
} from "./sections"
2727
import { loadSystemPromptFile } from "./sections/custom-system-prompt"
28+
import { formatLanguage } from "../../shared/language"
2829

2930
async function generatePrompt(
3031
context: vscode.ExtensionContext,
@@ -95,7 +96,7 @@ ${getSystemInfoSection(cwd, mode, customModeConfigs)}
9596
9697
${getObjectiveSection()}
9798
98-
${await addCustomInstructions(promptComponent?.customInstructions || modeConfig.customInstructions || "", globalCustomInstructions || "", cwd, mode, { vscodeLanguage: vscode.env.language, rooIgnoreInstructions })}`
99+
${await addCustomInstructions(promptComponent?.customInstructions || modeConfig.customInstructions || "", globalCustomInstructions || "", cwd, mode, { language: formatLanguage(vscode.env.language), rooIgnoreInstructions })}`
99100

100101
return basePrompt
101102
}
@@ -144,7 +145,7 @@ export const SYSTEM_PROMPT = async (
144145
globalCustomInstructions || "",
145146
cwd,
146147
mode,
147-
{ vscodeLanguage: vscode.env.language, rooIgnoreInstructions },
148+
{ language: formatLanguage(vscode.env.language), rooIgnoreInstructions },
148149
)
149150
// For file-based prompts, don't include the tool sections
150151
return `${roleDefinition}

src/core/webview/ClineProvider.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { checkoutDiffPayloadSchema, checkoutRestorePayloadSchema, WebviewMessage
2626
import { Mode, CustomModePrompts, PromptComponent, defaultModeSlug, ModeConfig } from "../../shared/modes"
2727
import { checkExistKey } from "../../shared/checkExistApiConfig"
2828
import { EXPERIMENT_IDS, experiments as Experiments, experimentDefault, ExperimentId } from "../../shared/experiments"
29+
import { formatLanguage } from "../../shared/language"
2930
import { downloadTask } from "../../integrations/misc/export-markdown"
3031
import { openFile, openImage } from "../../integrations/misc/open-file"
3132
import { selectImages } from "../../integrations/misc/process-images"
@@ -2358,6 +2359,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
23582359
browserToolEnabled,
23592360
telemetrySetting,
23602361
showRooIgnoredFiles,
2362+
language,
23612363
} = await this.getState()
23622364
const telemetryKey = process.env.POSTHOG_API_KEY
23632365
const machineId = vscode.env.machineId
@@ -2422,6 +2424,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
24222424
telemetryKey,
24232425
machineId,
24242426
showRooIgnoredFiles: showRooIgnoredFiles ?? true,
2427+
language,
24252428
}
24262429
}
24272430

@@ -2556,7 +2559,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
25562559
terminalOutputLineLimit: stateValues.terminalOutputLineLimit ?? 500,
25572560
mode: stateValues.mode ?? defaultModeSlug,
25582561
// Pass the VSCode language code directly
2559-
vscodeLanguage: vscode.env.language,
2562+
language: formatLanguage(vscode.env.language),
25602563
mcpEnabled: stateValues.mcpEnabled ?? true,
25612564
enableMcpServerCreation: stateValues.enableMcpServerCreation ?? true,
25622565
alwaysApproveResubmit: stateValues.alwaysApproveResubmit ?? false,

src/core/webview/__tests__/ClineProvider.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,12 +534,12 @@ describe("ClineProvider", () => {
534534
expect(state).toHaveProperty("writeDelayMs")
535535
})
536536

537-
test("vscodeLanguage is set to VSCode language", async () => {
537+
test("language is set to VSCode language", async () => {
538538
// Mock VSCode language as Spanish
539539
;(vscode.env as any).language = "es-ES"
540540

541541
const state = await provider.getState()
542-
expect(state.vscodeLanguage).toBe("es-ES")
542+
expect(state.language).toBe("es-ES")
543543
})
544544

545545
test("diffEnabled defaults to true when not set", async () => {

src/shared/ExtensionMessage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export interface ExtensionState {
131131
remoteBrowserHost?: string
132132
remoteBrowserEnabled?: boolean
133133
fuzzyMatchThreshold?: number
134-
vscodeLanguage?: string
134+
language?: string
135135
writeDelayMs: number
136136
terminalOutputLineLimit?: number
137137
mcpEnabled: boolean

0 commit comments

Comments
 (0)