Skip to content

Commit c6add86

Browse files
committed
Replace legacy dictionary error messages with i18n translations across editor commands and handlers
- move entries in `packages/shared/src/constants/dictionary.ts` to i18n └── apps └── editor └── src ├── commands │ ├── code-at-cursor-command │ │ └── utils │ │ └── perform-code-at-cursor.ts │ ├── new-file-command.ts │ ├── new-folder-command.ts │ └── select-modified-files-command.ts ├── i18n │ ├── index.ts │ └── translations │ ├── common.ts │ ├── services │ │ ├── index.ts │ │ └── websocket-manager.ts │ ├── utils │ │ ├── git-repository-utils.ts │ │ └── index.ts │ └── views │ ├── index.ts │ ├── prompt │ │ ├── handlers │ │ │ ├── handle-patch-repair.ts │ │ │ ├── index.ts │ │ │ └── utils │ │ │ ├── index.ts │ │ │ └── symbols │ │ │ ├── git │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ └── index.ts │ └── shared │ ├── actions │ │ ├── api │ │ │ ├── index.ts │ │ │ └── update │ │ │ ├── index.ts │ │ │ └── interactions │ │ │ └── index.ts │ │ ├── index.ts │ │ └── web │ │ └── index.ts │ └── index.ts ├── services │ └── websocket-manager.ts ├── utils │ └── send-llm-message.ts └── views ├── prompt │ └── backend │ ├── message-handlers │ │ ├── handle-go-to-file.ts │ │ ├── handle-hash-sign-quick-pick │ │ │ └── symbols │ │ │ ├── commit-symbol.ts │ │ │ └── saved-context-symbol.ts │ │ ├── handle-make-api-call.ts │ │ ├── handle-open-file-and-select.ts │ │ ├── handle-patch-repair.ts │ │ └── handle-show-diff.ts │ ├── prompt-view-provider.ts │ └── utils │ └── symbols │ └── git │ └── replace-git-symbols.ts ├── settings │ └── backend │ └── message-handlers │ └── handle-update-provider.ts └── shared └── actions ├── api │ └── update │ ├── interactions │ │ └── edit-model-for-api-config.ts │ └── update.ts └── web ├── delete.ts ├── pick-model.ts └── update.ts
1 parent 74cc770 commit c6add86

23 files changed

Lines changed: 517 additions & 130 deletions

File tree

‎apps/editor/src/commands/code-at-cursor-command/utils/perform-code-at-cursor.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
import { FilesCollector } from '../../../utils/files-collector'
1111
import { ProvidersManager } from '../../../services/providers-manager'
1212
import { Logger } from '@shared/utils/logger'
13-
import { dictionary } from '@shared/constants/dictionary'
1413
import { apply_reasoning_effort } from '../../../utils/apply-reasoning-effort'
1514
import { t } from '@/i18n'
1615
import { build_user_content } from '../../../utils/build-user-content'
@@ -357,7 +356,7 @@ export const perform_code_at_cursor = async (params: {
357356

358357
if (!code_at_cursor_api_configuration.provider_name) {
359358
vscode.window.showErrorMessage(
360-
dictionary.error_message.API_PROVIDER_NOT_SPECIFIED_FOR_CODE_AT_CURSOR
359+
t('common.error.api-provider-not-specified-for-code-at-cursor')
361360
)
362361
Logger.warn({
363362
function_name: 'perform_code_at_cursor',
@@ -367,7 +366,7 @@ export const perform_code_at_cursor = async (params: {
367366
continue
368367
} else if (!code_at_cursor_api_configuration.model) {
369368
vscode.window.showErrorMessage(
370-
dictionary.error_message.MODEL_NOT_SPECIFIED_FOR_CODE_AT_CURSOR
369+
t('common.error.model-not-specified-for-code-at-cursor')
371370
)
372371
Logger.warn({
373372
function_name: 'perform_code_at_cursor',

‎apps/editor/src/commands/new-file-command.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as vscode from 'vscode'
22
import * as path from 'path'
33
import * as fs from 'fs'
44
import { create_safe_path } from '../utils/path-sanitizer'
5-
import { dictionary } from '@shared/constants/dictionary'
65
import { Logger } from '@shared/utils/logger'
76
import { t } from '../i18n'
87

@@ -20,7 +19,7 @@ export const new_file_command = () => {
2019
parent_path = vscode.workspace.workspaceFolders[0].uri.fsPath
2120
} else {
2221
vscode.window.showErrorMessage(
23-
dictionary.error_message.NO_WORKSPACE_FOLDER_OPEN
22+
t('common.error.no-workspace-folder-open')
2423
)
2524
return
2625
}

‎apps/editor/src/commands/new-folder-command.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as vscode from 'vscode'
22
import * as path from 'path'
33
import * as fs from 'fs'
44
import { create_safe_path } from '../utils/path-sanitizer'
5-
import { dictionary } from '@shared/constants/dictionary'
65
import { Logger } from '@shared/utils/logger'
76
import { t } from '../i18n'
87

@@ -21,7 +20,7 @@ export const new_folder_command = () => {
2120
parent_path = vscode.workspace.workspaceFolders[0].uri.fsPath
2221
} else {
2322
vscode.window.showErrorMessage(
24-
dictionary.error_message.NO_WORKSPACE_FOLDER_OPEN
23+
t('common.error.no-workspace-folder-open')
2524
)
2625
return
2726
}

‎apps/editor/src/commands/select-modified-files-command.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as vscode from 'vscode'
22
import * as path from 'path'
33
import * as fs from 'fs'
44
import { WorkspaceProvider } from '../context/providers/workspace/workspace-provider'
5-
import { dictionary } from '@shared/constants/dictionary'
65
import { Logger } from '@shared/utils/logger'
76
import { t } from '@/i18n'
87
import { search_files } from '@/features/search-files'
@@ -29,7 +28,7 @@ export const select_modified_files_command = (
2928
const git_api = git_extension.getAPI(1)
3029
if (!git_api) {
3130
vscode.window.showErrorMessage(
32-
dictionary.error_message.COULD_NOT_GET_GIT_API
31+
t('common.error.could-not-get-git-api')
3332
)
3433
return
3534
}

‎apps/editor/src/i18n/translations/common.ts‎

Lines changed: 458 additions & 0 deletions
Large diffs are not rendered by default.

‎apps/editor/src/services/websocket-manager.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
} from '@shared/types/websocket-message'
1313
import { CHATBOTS } from '@shared/constants/chatbots'
1414
import { DEFAULT_PORT, SECURITY_TOKENS } from '@shared/constants/websocket'
15-
import { dictionary } from '@shared/constants/dictionary'
1615
import { Logger } from '@shared/utils/logger'
1716
import { WebConfiguration } from '@shared/types/web-configuration'
1817
import { ConfigWebConfigurationFormat } from '@/utils/web-configuration-format-converters'

‎apps/editor/src/utils/send-llm-message.ts‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as vscode from 'vscode'
22
import axios, { AxiosResponse } from 'axios'
3-
import { dictionary } from '@shared/constants/dictionary'
43
import { Logger } from '@shared/utils/logger'
4+
import { t } from '@/i18n'
55

66
type StreamCallback = (tokens_per_second: number, total_tokens: number) => void
77
type ThinkingStreamCallback = (text: string) => void
@@ -481,21 +481,15 @@ export const send_llm_message = async (params: {
481481
}
482482

483483
if (axios.isAxiosError(error) && error.response?.status == 429) {
484-
vscode.window.showErrorMessage(
485-
dictionary.error_message.API_RATE_LIMIT_EXCEEDED
486-
)
484+
vscode.window.showErrorMessage(t('common.error.api-rate-limit-exceeded'))
487485
} else if (axios.isAxiosError(error) && error.response?.status == 413) {
488-
vscode.window.showErrorMessage(
489-
dictionary.error_message.API_PAYLOAD_TOO_LARGE
490-
)
486+
vscode.window.showErrorMessage(t('common.error.api-payload-too-large'))
491487
} else if (axios.isAxiosError(error) && error.response?.status == 400) {
492-
vscode.window.showErrorMessage(dictionary.error_message.API_BAD_REQUEST)
488+
vscode.window.showErrorMessage(t('common.error.api-bad-request'))
493489
} else if (axios.isAxiosError(error) && error.response?.status == 401) {
494-
vscode.window.showErrorMessage(dictionary.error_message.API_INVALID_KEY)
490+
vscode.window.showErrorMessage(t('common.error.api-invalid-key'))
495491
} else {
496-
vscode.window.showErrorMessage(
497-
dictionary.error_message.API_REQUEST_FAILED
498-
)
492+
vscode.window.showErrorMessage(t('common.error.api-request-failed'))
499493
}
500494
Logger.error({
501495
function_name: 'send_llm_message',

‎apps/editor/src/views/prompt/backend/message-handlers/handle-go-to-file.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as vscode from 'vscode'
22
import { GoToFileMessage } from '@/views/prompt/types/messages'
33
import { Logger } from '@shared/utils/logger'
4-
import { dictionary } from '@shared/constants/dictionary'
4+
import { t } from '@/i18n'
55

66
export const handle_go_to_file = async (
77
message: GoToFileMessage
@@ -53,7 +53,7 @@ export const handle_go_to_file = async (
5353
data: { file_path }
5454
})
5555
vscode.window.showErrorMessage(
56-
dictionary.error_message.WORKSPACE_NOT_FOUND_FOR_FILE(file_path)
56+
t('common.error.workspace-not-found-for-file', { file_path })
5757
)
5858
return
5959
}
@@ -70,7 +70,7 @@ export const handle_go_to_file = async (
7070
data: { error, file_uri: file_uri.toString() }
7171
})
7272
vscode.window.showErrorMessage(
73-
dictionary.error_message.COULD_NOT_OPEN_FILE(file_path)
73+
t('common.error.could-not-open-file', { file_path })
7474
)
7575
}
7676
}

‎apps/editor/src/views/prompt/backend/message-handlers/handle-hash-sign-quick-pick/symbols/commit-symbol.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as vscode from 'vscode'
22
import { execSync } from 'child_process'
3-
import { dictionary } from '@shared/constants/dictionary'
43
import {
54
LAST_SELECTED_REPOSITORY_IN_SYMBOLS_QUCK_PICK_STATE_KEY,
65
LAST_SELECTED_COMMIT_REFERENCE_ACTION_STATE_KEY

‎apps/editor/src/views/prompt/backend/message-handlers/handle-hash-sign-quick-pick/symbols/saved-context-symbol.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as vscode from 'vscode'
22
import * as path from 'path'
3-
import { dictionary } from '@shared/constants/dictionary'
43
import { t } from '@/i18n'
54
import {
65
load_and_merge_global_contexts,
@@ -14,7 +13,7 @@ export const handle_saved_context_item = async (
1413
try {
1514
const workspace_folders = vscode.workspace.workspaceFolders || []
1615
if (workspace_folders.length == 0) {
17-
vscode.window.showErrorMessage(dictionary.error_message.NO_WORKSPACE_ROOT)
16+
vscode.window.showErrorMessage(t('common.error.no-workspace-root'))
1817
return undefined
1918
}
2019

0 commit comments

Comments
 (0)