Skip to content

Commit 0d81c0d

Browse files
authored
Merge pull request #1584 from RooVetGit/i18n
I18n
2 parents 9b5ee27 + 28e7451 commit 0d81c0d

Some content is hidden

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

56 files changed

+2281
-791
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": "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+
},
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/__mocks__/vscode.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
const vscode = {
2+
env: {
3+
language: "en", // Default language for tests
4+
appName: "Visual Studio Code Test",
5+
appHost: "desktop",
6+
appRoot: "/test/path",
7+
machineId: "test-machine-id",
8+
sessionId: "test-session-id",
9+
shell: "/bin/zsh",
10+
},
211
window: {
312
showInformationMessage: jest.fn(),
413
showErrorMessage: jest.fn(),

src/core/Cline.ts

Lines changed: 2 additions & 4 deletions
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"
@@ -1102,7 +1103,6 @@ export class Cline {
11021103
browserViewportSize,
11031104
mode,
11041105
customModePrompts,
1105-
preferredLanguage,
11061106
experiments,
11071107
enableMcpServerCreation,
11081108
browserToolEnabled,
@@ -1124,7 +1124,6 @@ export class Cline {
11241124
customModePrompts,
11251125
customModes,
11261126
this.customInstructions,
1127-
preferredLanguage,
11281127
this.diffEnabled,
11291128
experiments,
11301129
enableMcpServerCreation,
@@ -3665,13 +3664,12 @@ export class Cline {
36653664
customModePrompts,
36663665
experiments = {} as Record<ExperimentId, boolean>,
36673666
customInstructions: globalCustomInstructions,
3668-
preferredLanguage,
36693667
} = (await this.providerRef.deref()?.getState()) ?? {}
36703668
const currentMode = mode ?? defaultModeSlug
36713669
const modeDetails = await getFullModeDetails(currentMode, customModes, customModePrompts, {
36723670
cwd,
36733671
globalCustomInstructions,
3674-
preferredLanguage,
3672+
language: formatLanguage(vscode.env.language),
36753673
})
36763674
details += `\n\n# Current Mode\n`
36773675
details += `<slug>${currentMode}</slug>\n`

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

Lines changed: 1437 additions & 2 deletions
Large diffs are not rendered by default.

src/core/prompts/__tests__/custom-system-prompt.test.ts

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ const mockContext = {
4646
} as unknown as vscode.ExtensionContext
4747

4848
describe("File-Based Custom System Prompt", () => {
49-
const experiments = {}
50-
5149
beforeEach(() => {
5250
// Reset mocks before each test
5351
jest.clearAllMocks()
@@ -66,18 +64,17 @@ describe("File-Based Custom System Prompt", () => {
6664
const prompt = await SYSTEM_PROMPT(
6765
mockContext,
6866
"test/path", // Using a relative path without leading slash
69-
false,
70-
undefined,
71-
undefined,
72-
undefined,
73-
defaultModeSlug,
74-
customModePrompts,
75-
undefined,
76-
undefined,
77-
undefined,
78-
undefined,
79-
experiments,
80-
true,
67+
false, // supportsComputerUse
68+
undefined, // mcpHub
69+
undefined, // diffStrategy
70+
undefined, // browserViewportSize
71+
defaultModeSlug, // mode
72+
customModePrompts, // customModePrompts
73+
undefined, // customModes
74+
undefined, // globalCustomInstructions
75+
undefined, // diffEnabled
76+
undefined, // experiments
77+
true, // enableMcpServerCreation
8178
)
8279

8380
// Should contain default sections
@@ -101,26 +98,24 @@ describe("File-Based Custom System Prompt", () => {
10198
const prompt = await SYSTEM_PROMPT(
10299
mockContext,
103100
"test/path", // Using a relative path without leading slash
104-
false,
105-
undefined,
106-
undefined,
107-
undefined,
108-
defaultModeSlug,
109-
undefined,
110-
undefined,
111-
undefined,
112-
undefined,
113-
undefined,
114-
experiments,
115-
true,
101+
false, // supportsComputerUse
102+
undefined, // mcpHub
103+
undefined, // diffStrategy
104+
undefined, // browserViewportSize
105+
defaultModeSlug, // mode
106+
undefined, // customModePrompts
107+
undefined, // customModes
108+
undefined, // globalCustomInstructions
109+
undefined, // diffEnabled
110+
undefined, // experiments
111+
true, // enableMcpServerCreation
116112
)
117113

118114
// Should contain role definition and file-based system prompt
119115
expect(prompt).toContain(modes[0].roleDefinition)
120116
expect(prompt).toContain(fileCustomSystemPrompt)
121117

122118
// Should not contain any of the default sections
123-
expect(prompt).not.toContain("TOOL USE")
124119
expect(prompt).not.toContain("CAPABILITIES")
125120
expect(prompt).not.toContain("MODES")
126121
})
@@ -146,26 +141,24 @@ describe("File-Based Custom System Prompt", () => {
146141
const prompt = await SYSTEM_PROMPT(
147142
mockContext,
148143
"test/path", // Using a relative path without leading slash
149-
false,
150-
undefined,
151-
undefined,
152-
undefined,
153-
defaultModeSlug,
154-
customModePrompts,
155-
undefined,
156-
undefined,
157-
undefined,
158-
undefined,
159-
experiments,
160-
true,
144+
false, // supportsComputerUse
145+
undefined, // mcpHub
146+
undefined, // diffStrategy
147+
undefined, // browserViewportSize
148+
defaultModeSlug, // mode
149+
customModePrompts, // customModePrompts
150+
undefined, // customModes
151+
undefined, // globalCustomInstructions
152+
undefined, // diffEnabled
153+
undefined, // experiments
154+
true, // enableMcpServerCreation
161155
)
162156

163157
// Should contain custom role definition and file-based system prompt
164158
expect(prompt).toContain(customRoleDefinition)
165159
expect(prompt).toContain(fileCustomSystemPrompt)
166160

167161
// Should not contain any of the default sections
168-
expect(prompt).not.toContain("TOOL USE")
169162
expect(prompt).not.toContain("CAPABILITIES")
170163
expect(prompt).not.toContain("MODES")
171164
})

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import { getCapabilitiesSection } from "../sections/capabilities"
33
import { DiffStrategy, DiffResult } from "../../diff/types"
44

55
describe("addCustomInstructions", () => {
6-
test("adds preferred language to custom instructions", async () => {
6+
test("adds vscode language to custom instructions", async () => {
77
const result = await addCustomInstructions(
88
"mode instructions",
99
"global instructions",
1010
"/test/path",
1111
"test-mode",
12-
{ preferredLanguage: "French" },
12+
{ language: "fr" },
1313
)
1414

1515
expect(result).toContain("Language Preference:")
16-
expect(result).toContain("You should always speak and think in the French language")
16+
expect(result).toContain('You should always speak and think in the "fr" language')
1717
})
1818

19-
test("works without preferred language", async () => {
19+
test("works without vscode language", async () => {
2020
const result = await addCustomInstructions(
2121
"mode instructions",
2222
"global instructions",

0 commit comments

Comments
 (0)