Skip to content

Commit 0e424b8

Browse files
committed
Implement i18n support for all command strings and user interface messages across the application
1 parent 69e4df3 commit 0e424b8

37 files changed

Lines changed: 2510 additions & 199 deletions

apps/editor/src/commands/add-file-to-context-command.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
FileItem
66
} from '../context/providers/workspace/workspace-provider'
77
import { natural_sort } from '../utils/natural-sort'
8+
import { t } from '../i18n'
89

910
interface FileQuickPickItem extends vscode.QuickPickItem {
1011
full_path: string
@@ -33,17 +34,17 @@ export const add_file_to_context_command = (
3334
(resolve) => {
3435
const quick_pick = vscode.window.createQuickPick()
3536
quick_pick.items = items
36-
quick_pick.placeholder = 'Select a workspace folder to browse files'
37-
quick_pick.title = 'Workspace Folders'
37+
quick_pick.placeholder = t('command.context.add.select-workspace')
38+
quick_pick.title = t('command.context.workspace-folders')
3839
quick_pick.buttons = [
3940
{
4041
iconPath: new vscode.ThemeIcon('close'),
41-
tooltip: 'Close'
42+
tooltip: t('common.close')
4243
}
4344
]
4445

4546
quick_pick.onDidTriggerButton((button) => {
46-
if (button.tooltip == 'Close') {
47+
if (button.tooltip == t('common.close')) {
4748
quick_pick.hide()
4849
}
4950
})
@@ -70,20 +71,20 @@ export const add_file_to_context_command = (
7071
}
7172

7273
const quick_pick = vscode.window.createQuickPick<FileQuickPickItem>()
73-
quick_pick.title = 'Workspace Files'
74-
quick_pick.placeholder = 'Select a file to add to context'
74+
quick_pick.title = t('command.context.workspace-files')
75+
quick_pick.placeholder = t('command.context.add.select-file')
7576
quick_pick.matchOnDescription = true
7677
quick_pick.buttons = [
7778
{
7879
iconPath: new vscode.ThemeIcon('close'),
79-
tooltip: 'Close'
80+
tooltip: t('common.close')
8081
}
8182
]
8283
quick_pick.busy = true
8384
quick_pick.show()
8485

8586
quick_pick.onDidTriggerButton((button) => {
86-
if (button.tooltip == 'Close') {
87+
if (button.tooltip == t('common.close')) {
8788
quick_pick.hide()
8889
}
8990
})
@@ -95,7 +96,7 @@ export const add_file_to_context_command = (
9596

9697
quick_pick.onDidTriggerItemButton(async (e) => {
9798
const item = e.item
98-
if (e.button.tooltip == 'Add Parent Folder to Context') {
99+
if (e.button.tooltip == t('command.context.add.add-parent-folder')) {
99100
parent_folder_source_full_path = item.full_path
100101

101102
const workspace_root = workspace_provider.get_workspace_root_for_file(
@@ -120,16 +121,18 @@ export const add_file_to_context_command = (
120121
}
121122

122123
if (folders.length == 0) {
123-
vscode.window.showInformationMessage('No parent folders to add.')
124+
vscode.window.showInformationMessage(
125+
t('command.context.add.no-parent-folders')
126+
)
124127
return
125128
}
126129

127130
const folder_quick_pick = vscode.window.createQuickPick<{
128131
label: string
129132
full_path: string
130133
}>()
131-
folder_quick_pick.title = 'Parent Folders'
132-
folder_quick_pick.placeholder = 'Select a folder to add to context'
134+
folder_quick_pick.title = t('command.context.parent-folders')
135+
folder_quick_pick.placeholder = t('command.context.add.select-folder')
133136
folder_quick_pick.items = folders.map((f) => ({
134137
label: f.label,
135138
full_path: f.full_path
@@ -241,7 +244,7 @@ export const add_file_to_context_command = (
241244
? [
242245
{
243246
iconPath: new vscode.ThemeIcon('folder'),
244-
tooltip: 'Add Parent Folder to Context'
247+
tooltip: t('command.context.add.add-parent-folder')
245248
}
246249
]
247250
: []

apps/editor/src/commands/apply-chat-response-command/apply-chat-response-command.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { CHECKPOINTS_STATE_KEY } from '@/constants/state-keys'
2222
import { ResponseHistoryItem } from '@shared/types/response-history-item'
2323
import { ApiManager } from '@/services/api-manager'
2424
import { parse_response } from './utils/clipboard-parser/clipboard-parser'
25+
import { t } from '@/i18n'
2526

2627
let in_progress = false
2728
let placeholder_created_at_for_update: number | undefined
@@ -143,7 +144,7 @@ export const apply_chat_response_command = (params: {
143144
if (file_count > 0) {
144145
params.panel_provider.send_message({
145146
command: 'SHOW_PROGRESS',
146-
title: 'Preparing response preview...',
147+
title: t('command.apply-chat-response.progress.preparing-preview'),
147148
delay_visibility: file_count == 1
148149
})
149150
}

apps/editor/src/commands/apply-chat-response-command/response-processor.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { handle_conflict_markers } from './handlers/conflict-markers-handler'
2727
import { handle_truncated_edit } from './handlers/truncated-handler'
2828
import { WorkspaceProvider } from '@/context/providers/workspace/workspace-provider'
2929
import { natural_sort } from '@/utils/natural-sort'
30+
import { t } from '@/i18n'
3031
import { is_truncation_line } from './utils/edit-formats/truncations'
3132

3233
export type PreviewData = {
@@ -142,10 +143,12 @@ export const process_chat_response = async (
142143
quick_pick.items = quick_pick_items
143144
quick_pick.selectedItems = quick_pick_items.filter((i) => i.picked)
144145
quick_pick.canSelectMany = true
145-
quick_pick.title = 'Context Pruning'
146-
quick_pick.placeholder = 'Confirm file selection'
146+
quick_pick.title = t('command.apply-chat-response.context-pruning.title')
147+
quick_pick.placeholder = t(
148+
'command.apply-chat-response.context-pruning.placeholder'
149+
)
147150
quick_pick.buttons = [
148-
{ iconPath: new vscode.ThemeIcon('close'), tooltip: 'Close' }
151+
{ iconPath: new vscode.ThemeIcon('close'), tooltip: t('common.close') }
149152
]
150153

151154
const selected_items = await new Promise<
@@ -193,7 +196,9 @@ export const process_chat_response = async (
193196

194197
if (files_to_check.length > 0) {
195198
await workspace_provider.set_checked_files(files_to_check)
196-
vscode.window.showInformationMessage(`Context pruned successfully.`)
199+
vscode.window.showInformationMessage(
200+
t('command.apply-chat-response.context-pruning.success')
201+
)
197202
}
198203
}
199204

@@ -403,15 +408,20 @@ export const process_chat_response = async (
403408
const editor = vscode.window.activeTextEditor
404409
if (editor) {
405410
const choice = await vscode.window.showWarningMessage(
406-
'No valid code blocks found',
411+
t('command.apply-chat-response.warning.no-code-blocks.title'),
407412
{
408413
modal: true,
409-
detail: 'Apply the clipboard text to the active editor?'
414+
detail: t(
415+
'command.apply-chat-response.warning.no-code-blocks.detail'
416+
)
410417
},
411-
'Apply with Intelligent Update'
418+
t('command.apply-chat-response.warning.no-code-blocks.action')
412419
)
413420

414-
if (choice == 'Apply with Intelligent Update') {
421+
if (
422+
choice ==
423+
t('command.apply-chat-response.warning.no-code-blocks.action')
424+
) {
415425
const document = editor.document
416426
const file_path_for_block = vscode.workspace
417427
.asRelativePath(document.uri, !is_single_root_folder_workspace)

apps/editor/src/commands/apply-context-command/apply-context-command.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
get_contexts_file_path,
1515
load_and_merge_global_contexts
1616
} from './helpers/saving'
17+
import { t } from '@/i18n'
1718

1819
export const apply_context_command = (params: {
1920
workspace_provider: WorkspaceProvider
@@ -48,7 +49,7 @@ export const apply_context_command = (params: {
4849
})[] = []
4950

5051
main_quick_pick_options.push({
51-
label: 'Workspace state',
52+
label: t('command.apply-context.sources.workspace-state'),
5253
description: `${internal_contexts.length} ${
5354
internal_contexts.length == 1 ? 'entry' : 'entries'
5455
}`,
@@ -57,11 +58,11 @@ export const apply_context_command = (params: {
5758

5859
const open_file_button = {
5960
iconPath: new vscode.ThemeIcon('go-to-file'),
60-
tooltip: 'Open contexts.json'
61+
tooltip: t('command.apply-context.action.open-json')
6162
}
6263

6364
main_quick_pick_options.push({
64-
label: 'JSON file',
65+
label: t('command.apply-context.sources.json-file'),
6566
description: `${file_contexts_count} ${
6667
file_contexts_count == 1 ? 'entry' : 'entries'
6768
}`,
@@ -70,12 +71,12 @@ export const apply_context_command = (params: {
7071
})
7172

7273
main_quick_pick_options.push({
73-
label: 'Unstaged files',
74+
label: t('command.apply-context.sources.unstaged-files'),
7475
value: 'unstaged'
7576
})
7677

7778
main_quick_pick_options.push({
78-
label: 'Files touched by a commit...',
79+
label: t('command.apply-context.sources.commit-files'),
7980
value: 'commit_files'
8081
})
8182

@@ -84,9 +85,11 @@ export const apply_context_command = (params: {
8485
value: 'internal' | 'file' | 'unstaged' | 'commit_files' | string
8586
}
8687
>()
87-
main_quick_pick.title = 'Context Sources'
88+
main_quick_pick.title = t('command.apply-context.sources.title')
8889
main_quick_pick.items = main_quick_pick_options
89-
main_quick_pick.placeholder = 'Select option'
90+
main_quick_pick.placeholder = t(
91+
'command.apply-context.sources.placeholder'
92+
)
9093
main_quick_pick.buttons = [
9194
{ iconPath: new vscode.ThemeIcon('close'), tooltip: 'Close' }
9295
]

apps/editor/src/commands/apply-context-command/helpers/applying/apply-saved-context.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { LAST_CONTEXT_MERGE_REPLACE_OPTION_STATE_KEY } from '../../../../constan
44
import { SavedContext } from '@/types/context'
55
import { dictionary } from '@shared/constants/dictionary'
66
import { resolve_context_paths } from './resolve-context-paths'
7+
import { t } from '@/i18n'
78

89
export const apply_saved_context = async (
910
context: SavedContext,
@@ -37,14 +38,18 @@ export const apply_saved_context = async (
3738
)
3839

3940
if (!all_current_files_in_new_context) {
40-
const quick_pick_options = [
41+
const quick_pick_options: (vscode.QuickPickItem & {
42+
action_id: string
43+
})[] = [
4144
{
42-
label: 'Replace',
43-
description: 'Replace the current context with the selected one'
45+
action_id: 'Replace',
46+
label: t('command.apply-context.action.replace.label'),
47+
description: t('command.apply-context.action.replace.description')
4448
},
4549
{
46-
label: 'Merge',
47-
description: 'Merge the selected context with the current one'
50+
action_id: 'Merge',
51+
label: t('command.apply-context.action.merge.label'),
52+
description: t('command.apply-context.action.merge.description')
4853
}
4954
]
5055

@@ -54,20 +59,22 @@ export const apply_saved_context = async (
5459

5560
const quick_pick = vscode.window.createQuickPick()
5661
quick_pick.items = quick_pick_options
57-
quick_pick.placeholder = `How would you like to apply "${context.name}"?`
62+
quick_pick.placeholder = t('command.apply-context.apply.placeholder', {
63+
name: context.name
64+
})
5865
quick_pick.buttons = [vscode.QuickInputButtons.Back]
5966

6067
if (last_choice_label) {
6168
const active_item = quick_pick_options.find(
62-
(opt) => opt.label === last_choice_label
69+
(opt) => opt.action_id === last_choice_label
6370
)
6471
if (active_item) {
6572
quick_pick.activeItems = [active_item]
6673
}
6774
}
6875

6976
const choice = await new Promise<
70-
vscode.QuickPickItem | 'back' | undefined
77+
(vscode.QuickPickItem & { action_id: string }) | 'back' | undefined
7178
>((resolve) => {
7279
let is_accepted = false
7380
quick_pick.onDidTriggerButton((button) => {
@@ -78,7 +85,11 @@ export const apply_saved_context = async (
7885
})
7986
quick_pick.onDidAccept(() => {
8087
is_accepted = true
81-
resolve(quick_pick.selectedItems[0])
88+
resolve(
89+
quick_pick.selectedItems[0] as vscode.QuickPickItem & {
90+
action_id: string
91+
}
92+
)
8293
quick_pick.hide()
8394
})
8495
quick_pick.onDidHide(() => {
@@ -100,9 +111,9 @@ export const apply_saved_context = async (
100111

101112
await extension_context.workspaceState.update(
102113
LAST_CONTEXT_MERGE_REPLACE_OPTION_STATE_KEY,
103-
choice.label
114+
choice.action_id
104115
)
105-
if (choice.label == 'Merge') {
116+
if (choice.action_id == 'Merge') {
106117
paths_to_apply = [
107118
...new Set([...currently_checked_files, ...existing_paths])
108119
]

apps/editor/src/commands/apply-context-command/helpers/saving/ask-for-new-context-name.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import * as vscode from 'vscode'
2-
3-
const PROMPT_ENTER_CONTEXT_NAME = 'Enter a name for this context'
4-
const PLACEHOLDER_CONTEXT_NAME = 'e.g., Backend API Context'
5-
const VALIDATION_CONTEXT_NAME_EMPTY = 'Context name cannot be empty.'
2+
import { t } from '@/i18n'
63

74
export const ask_for_new_context_name = async (
85
with_back_button: boolean
96
): Promise<string | 'back' | undefined> => {
107
const input_box = vscode.window.createInputBox()
11-
input_box.title = 'New Entry'
12-
input_box.prompt = PROMPT_ENTER_CONTEXT_NAME
13-
input_box.placeholder = PLACEHOLDER_CONTEXT_NAME
8+
input_box.title = t('command.apply-context.ask-name.title')
9+
input_box.prompt = t('command.apply-context.ask-name.prompt')
10+
input_box.placeholder = t('command.apply-context.ask-name.placeholder')
1411

1512
return new Promise((resolve) => {
1613
let accepted = false
@@ -20,7 +17,9 @@ export const ask_for_new_context_name = async (
2017
input_box.onDidAccept(() => {
2118
const value = input_box.value.trim()
2219
if (value.length == 0) {
23-
input_box.validationMessage = VALIDATION_CONTEXT_NAME_EMPTY
20+
input_box.validationMessage = t(
21+
'command.apply-context.ask-name.empty'
22+
)
2423
return
2524
}
2625
accepted = true

0 commit comments

Comments
 (0)