Skip to content

Commit 8816f3d

Browse files
committed
Migrate checkpoint feature messages to the centralized translation system
- we should have `apps/editor/src/i18n/translations/features/index.ts` and `apps/editor/src/i18n/translations/features/search-files.ts` - checkpoints feature misses translations - favor i18n over dictionary for `apps/editor/src/commands/history-command.ts`
1 parent fb7e850 commit 8816f3d

11 files changed

Lines changed: 494 additions & 172 deletions

File tree

‎apps/editor/src/commands/history-command.ts‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
} from '@/features/checkpoints/actions'
2121
import { PanelProvider } from '@/views/panel/backend/panel-provider'
2222
import { get_checkpoint_path } from '@/features/checkpoints/utils'
23-
import { dictionary } from '@shared/constants/dictionary'
2423
import { get_response_preview_promise_resolve } from '@/commands/apply-response-command/utils/preview/preview'
2524

2625
dayjs.extend(localizedFormat)
@@ -49,7 +48,7 @@ export const history_command = (params: {
4948
vscode.workspace.workspaceFolders.length == 0
5049
) {
5150
vscode.window.showErrorMessage(
52-
dictionary.error_message.CHECKPOINTS_ONLY_IN_WORKSPACE
51+
t('command.history.error.checkpoints-only-in-workspace')
5352
)
5453
return
5554
}
@@ -81,7 +80,7 @@ export const history_command = (params: {
8180
vscode.workspace.workspaceFolders.length == 0
8281
) {
8382
vscode.window.showErrorMessage(
84-
dictionary.error_message.CHECKPOINTS_ONLY_IN_WORKSPACE
83+
t('command.history.error.checkpoints-only-in-workspace')
8584
)
8685
return
8786
}
@@ -257,8 +256,7 @@ export const history_command = (params: {
257256
)
258257
if (!temp_checkpoint) {
259258
vscode.window.showErrorMessage(
260-
dictionary.error_message
261-
.COULD_NOT_FIND_TEMP_CHECKPOINT_TO_REVERT
259+
t('command.history.error.could-not-find-temp-checkpoint')
262260
)
263261
return
264262
}
@@ -306,23 +304,23 @@ export const history_command = (params: {
306304
)
307305
if (checkpoints.length == 0 && !temp_checkpoint) {
308306
vscode.window.showInformationMessage(
309-
dictionary.information_message.NOTHING_TO_DELETE
307+
t('command.history.info.nothing-to-delete')
310308
)
311309
quick_pick.show()
312310
return
313311
}
314312

315313
const confirmation = await vscode.window.showWarningMessage(
316-
dictionary.warning_message.CONFIRM_CLEAR_ALL_CHECKPOINTS,
314+
t('command.history.warning.confirm-clear-all'),
317315
{ modal: true },
318-
'Clear All'
316+
t('command.history.clear-all-button')
319317
)
320318

321-
if (confirmation == 'Clear All') {
319+
if (confirmation == t('command.history.clear-all-button')) {
322320
active_delete_operation = null
323-
await clear_all_checkpoints(params.context, params.panel_provider)
321+
await clear_all_checkpoints(params.context)
324322
vscode.window.showInformationMessage(
325-
dictionary.information_message.ALL_CHECKPOINTS_CLEARED
323+
t('command.history.info.all-cleared')
326324
)
327325
}
328326
await refresh_and_update_view()

‎apps/editor/src/features/checkpoints/actions/clear-all-checkpoints.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import {
66
import { get_checkpoint_path } from '../utils'
77
import { get_checkpoints } from './get-checkpoints'
88
import { Logger } from '@shared/utils/logger'
9-
import { PanelProvider } from '@/views/panel/backend/panel-provider'
109
import type { Checkpoint } from '../types'
10+
import { t } from '@/i18n'
1111

1212
export const clear_all_checkpoints = async (
13-
context: vscode.ExtensionContext,
14-
panel_provider: PanelProvider
13+
context: vscode.ExtensionContext
1514
) => {
1615
const clear_task = async () => {
1716
const checkpoints = await get_checkpoints(context)
@@ -55,7 +54,7 @@ export const clear_all_checkpoints = async (
5554
await vscode.window.withProgress(
5655
{
5756
location: vscode.ProgressLocation.Notification,
58-
title: 'Clearing all checkpoints...',
57+
title: t('feature.checkpoints.progress.clearing-all'),
5958
cancellable: false
6059
},
6160
clear_task

‎apps/editor/src/features/checkpoints/actions/create-checkpoint.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import {
2020
import * as path from 'path'
2121
import { Logger } from '@shared/utils/logger'
2222
import { PanelProvider } from '@/views/panel/backend/panel-provider'
23-
import { dictionary } from '@shared/constants/dictionary'
2423
import { response_preview_promise_resolve } from '@/commands/apply-response-command/utils/preview'
24+
import { t } from '@/i18n'
2525

2626
export const create_checkpoint = async (params: {
2727
workspace_provider: WorkspaceProvider
@@ -54,7 +54,7 @@ export const create_checkpoint = async (params: {
5454
Date.now() - operation_in_progress < 60 * 1000
5555
) {
5656
vscode.window.showWarningMessage(
57-
dictionary.warning_message.CHECKPOINT_OPERATION_IN_PROGRESS
57+
t('feature.checkpoints.warning.operation-in-progress')
5858
)
5959
return undefined
6060
}
@@ -230,7 +230,7 @@ export const create_checkpoint = async (params: {
230230
return new_checkpoint
231231
} catch (err: any) {
232232
vscode.window.showErrorMessage(
233-
`Failed to create checkpoint: ${err.message}`
233+
t('feature.checkpoints.error.create-failed', { error: err.message })
234234
)
235235
await params.context.workspaceState.update(
236236
CHECKPOINT_OPERATION_IN_PROGRESS_STATE_KEY,

‎apps/editor/src/features/checkpoints/actions/delete-checkpoint.ts‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { Checkpoint } from '../types'
44
import { get_checkpoint_path } from '../utils'
55
import { Logger } from '@shared/utils/logger'
66
import { PanelProvider } from '@/views/panel/backend/panel-provider'
7-
import { dictionary } from '@shared/constants/dictionary'
7+
import { t } from '@/i18n'
88

99
export const delete_checkpoint = async (params: {
1010
context: vscode.ExtensionContext
@@ -83,9 +83,9 @@ export const delete_checkpoint_with_undo = async (params: {
8383
})
8484
} catch (error: any) {
8585
vscode.window.showWarningMessage(
86-
dictionary.warning_message.COULD_NOT_DELETE_CHECKPOINT_FILES(
87-
error.message
88-
)
86+
t('feature.checkpoints.warning.could-not-delete', {
87+
error: error.message
88+
})
8989
)
9090
}
9191
}
@@ -94,9 +94,10 @@ export const delete_checkpoint_with_undo = async (params: {
9494
params.set_active_operation(operation)
9595

9696
params.on_before_show_message?.()
97+
const undo_action = t('feature.checkpoints.action.undo')
9798
const choice = await vscode.window.showInformationMessage(
98-
dictionary.information_message.CHECKPOINT_DELETED,
99-
'Undo'
99+
t('feature.checkpoints.success.deleted'),
100+
undo_action
100101
)
101102
params.on_after_show_message?.()
102103

@@ -106,7 +107,7 @@ export const delete_checkpoint_with_undo = async (params: {
106107
current_active_op &&
107108
current_active_op.timestamp === operation.timestamp
108109
) {
109-
if (choice == 'Undo') {
110+
if (choice == undo_action) {
110111
const current_checkpoints =
111112
params.context.workspaceState.get<Checkpoint[]>(
112113
CHECKPOINTS_STATE_KEY,
@@ -124,7 +125,7 @@ export const delete_checkpoint_with_undo = async (params: {
124125

125126
params.on_before_show_message?.()
126127
await vscode.window.showInformationMessage(
127-
dictionary.information_message.CHECKPOINT_RESTORED
128+
t('feature.checkpoints.success.restored')
128129
)
129130
params.on_after_show_message?.()
130131

@@ -135,10 +136,10 @@ export const delete_checkpoint_with_undo = async (params: {
135136
params.set_active_operation(null)
136137
return false
137138
}
138-
} else if (choice == 'Undo') {
139+
} else if (choice == undo_action) {
139140
params.on_before_show_message?.()
140141
await vscode.window.showInformationMessage(
141-
dictionary.information_message.COULD_NOT_UNDO_ANOTHER_CHECKPOINT_DELETED
142+
t('feature.checkpoints.error.could-not-undo')
142143
)
143144
params.on_after_show_message?.()
144145
return false

‎apps/editor/src/features/checkpoints/actions/restore-checkpoint.ts‎

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import { Logger } from '@shared/utils/logger'
1919
import { PanelProvider } from '@/views/panel/backend/panel-provider'
2020
import { response_preview_promise_resolve } from '@/commands/apply-response-command/utils/preview'
2121
import { ongoing_preview_cleanup_promise } from '@/commands/apply-response-command/utils/preview-handler'
22-
import { dictionary } from '@shared/constants/dictionary'
2322
import { get_git_info } from '../utils/git-utils'
2423
import { PromptsForCommitMessagesUtils } from '@/utils/prompts-for-commit-messages-utils'
24+
import { t } from '@/i18n'
2525
export const restore_checkpoint = async (params: {
2626
checkpoint: Checkpoint
2727
workspace_provider: WorkspaceProvider
@@ -36,14 +36,14 @@ export const restore_checkpoint = async (params: {
3636
)
3737
if (operation_in_progress && Date.now() - operation_in_progress < 60 * 1000) {
3838
vscode.window.showWarningMessage(
39-
dictionary.warning_message.CHECKPOINT_OPERATION_IN_PROGRESS
39+
t('feature.checkpoints.warning.operation-in-progress')
4040
)
4141
return
4242
}
4343

4444
const title = params.options?.skip_confirmation
45-
? 'Reverting...'
46-
: 'Restoring checkpoint...'
45+
? t('feature.checkpoints.progress.reverting')
46+
: t('feature.checkpoints.progress.restoring')
4747

4848
const main_task = async (
4949
progress: vscode.Progress<{ message?: string; increment?: number }>
@@ -139,7 +139,9 @@ export const restore_checkpoint = async (params: {
139139
}
140140
} catch (err: any) {
141141
vscode.window.showErrorMessage(
142-
`Failed to create temporary checkpoint for revert: ${err.message}`
142+
t('feature.checkpoints.error.create-temp-failed', {
143+
error: err.message
144+
})
143145
)
144146
await params.context.workspaceState.update(
145147
TEMPORARY_CHECKPOINT_STATE_KEY,
@@ -202,7 +204,9 @@ export const restore_checkpoint = async (params: {
202204
data: e
203205
})
204206
throw new Error(
205-
`Failed to reject changes for ${folder.name}. Please ensure your git working directory is clean.`
207+
t('feature.checkpoints.error.reject-changes-failed', {
208+
folder: folder.name
209+
})
206210
)
207211
}
208212
}
@@ -250,7 +254,9 @@ export const restore_checkpoint = async (params: {
250254
}
251255
)
252256
vscode.window.showWarningMessage(
253-
`Some changes for ${folder.name} could not be applied cleanly during checkpoint restore. Check for .rej files in your workspace.`
257+
t('feature.checkpoints.warning.diff-apply-issues', {
258+
folder: folder.name
259+
})
254260
)
255261
} catch (rejectErr) {
256262
Logger.error({
@@ -259,7 +265,9 @@ export const restore_checkpoint = async (params: {
259265
data: rejectErr
260266
})
261267
throw new Error(
262-
`Failed to apply git diff for ${folder.name}`
268+
t('feature.checkpoints.error.diff-apply-failed', {
269+
folder: folder.name
270+
})
263271
)
264272
}
265273
} finally {
@@ -336,7 +344,9 @@ export const restore_checkpoint = async (params: {
336344
}
337345
)
338346
vscode.window.showWarningMessage(
339-
`Some changes for ${folder.name} could not be applied cleanly during checkpoint restore. Check for .rej files in your workspace.`
347+
t('feature.checkpoints.warning.diff-apply-issues', {
348+
folder: folder.name
349+
})
340350
)
341351
} catch (rejectErr) {
342352
Logger.error({
@@ -345,7 +355,9 @@ export const restore_checkpoint = async (params: {
345355
data: rejectErr
346356
})
347357
throw new Error(
348-
`Failed to apply git diff for ${folder.name}`
358+
t('feature.checkpoints.error.diff-apply-failed', {
359+
folder: folder.name
360+
})
349361
)
350362
}
351363
} finally {
@@ -489,7 +501,7 @@ export const restore_checkpoint = async (params: {
489501
undefined
490502
)
491503
vscode.window.showErrorMessage(
492-
`Failed to restore checkpoint: ${err.message}`
504+
t('feature.checkpoints.error.restore-failed', { error: err.message })
493505
)
494506
if (temp_checkpoint) {
495507
await delete_checkpoint({
@@ -523,12 +535,16 @@ export const restore_checkpoint = async (params: {
523535
}
524536

525537
const message = params.options?.skip_confirmation
526-
? 'Successfully reverted changes.'
527-
: 'Checkpoint has been restored.'
538+
? t('feature.checkpoints.success.reverted')
539+
: t('feature.checkpoints.success.restored')
528540

529541
if (temp_check) {
530-
const action = await vscode.window.showInformationMessage(message, 'Revert')
531-
if (action == 'Revert') {
542+
const action_label = t('feature.checkpoints.action.revert')
543+
const action = await vscode.window.showInformationMessage(
544+
message,
545+
action_label
546+
)
547+
if (action == action_label) {
532548
await restore_checkpoint({
533549
checkpoint: temp_check,
534550
workspace_provider: params.workspace_provider,

‎apps/editor/src/i18n/index.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { translations as views_shared_actions_web_delete } from './translations/
2121
import { translations as views_shared_actions_web_pick_chatbot } from './translations/views/shared/actions/web/pick-chatbot'
2222
import { translations as views_shared_actions_web_pick_model } from './translations/views/shared/actions/web/pick-model'
2323
import { translations as views_shared_actions_web_update } from './translations/views/shared/actions/web/update'
24-
import { translations as features_search_files } from './translations/features/search-files'
24+
import { translations as features } from './translations/features'
2525

2626
export type TranslationKey = keyof typeof translations
2727

@@ -48,7 +48,7 @@ const translations = {
4848
...views_shared_actions_web_pick_chatbot,
4949
...views_shared_actions_web_pick_model,
5050
...views_shared_actions_web_update,
51-
...features_search_files
51+
...features
5252
}
5353

5454
export const t = (

0 commit comments

Comments
 (0)