Skip to content

Commit 69e4df3

Browse files
committed
Replace hardcoded UI strings with i18n translations in code-at-cursor commands and progress messages
1 parent f5fd6c8 commit 69e4df3

5 files changed

Lines changed: 145 additions & 36 deletions

File tree

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { ToolConfig } from '@/services/model-providers-manager'
1515
import { PanelProvider } from '@/views/panel/backend/panel-provider'
1616
import { dictionary } from '@shared/constants/dictionary'
1717
import { apply_reasoning_effort } from '../utils/apply-reasoning-effort'
18-
import { display_token_count } from '../utils/display-token-count'
18+
import { t } from '@/i18n'
1919

2020
const show_ghost_text = async (params: {
2121
editor: vscode.TextEditor
@@ -155,7 +155,7 @@ const get_code_at_cursor_config = async (params: {
155155

156156
if (recent_configs.length > 0) {
157157
items.push({
158-
label: 'recently used',
158+
label: t('common.separator.recently-used'),
159159
kind: vscode.QuickPickItemKind.Separator
160160
})
161161
items.push(...recent_configs.map(map_config_to_item))
@@ -164,7 +164,7 @@ const get_code_at_cursor_config = async (params: {
164164
if (other_configs.length > 0) {
165165
if (recent_configs.length > 0) {
166166
items.push({
167-
label: 'other configurations',
167+
label: t('common.config.other'),
168168
kind: vscode.QuickPickItemKind.Separator
169169
})
170170
}
@@ -176,7 +176,7 @@ const get_code_at_cursor_config = async (params: {
176176

177177
const quick_pick = vscode.window.createQuickPick()
178178
quick_pick.items = create_items()
179-
quick_pick.placeholder = 'Select code at cursor configuration'
179+
quick_pick.placeholder = t('command.code-at-cursor.config.placeholder')
180180
quick_pick.matchOnDescription = true
181181

182182
const items = quick_pick.items as (vscode.QuickPickItem & { id: string })[]
@@ -287,8 +287,8 @@ const perform_code_at_cursor = async (params: {
287287
'last-completion-instructions'
288288
) || ''
289289
completion_instructions = await vscode.window.showInputBox({
290-
placeHolder: 'Enter completion instructions',
291-
prompt: 'E.g. "Include explanatory comments".',
290+
placeHolder: t('command.code-at-cursor.instructions.placeholder'),
291+
prompt: t('command.code-at-cursor.instructions.prompt'),
292292
value: last_value
293293
})
294294

@@ -413,25 +413,25 @@ const perform_code_at_cursor = async (params: {
413413
})
414414

415415
const cursor_listener = vscode.window.onDidChangeTextEditorSelection(() => {
416-
cancel_token_source.cancel('User moved the cursor, cancelling request.')
416+
cancel_token_source.cancel(
417+
t('command.code-at-cursor.cancel.cursor-moved')
418+
)
417419
})
418420

419421
try {
420422
const completion_result = await vscode.window.withProgress(
421423
{
422424
location: vscode.ProgressLocation.Notification,
423-
title: 'Requested code at cursor',
425+
title: t('command.code-at-cursor.progress.title'),
424426
cancellable: true
425427
},
426428
async (progress, token) => {
427429
token.onCancellationRequested(() => {
428-
cancel_token_source.cancel('User cancelled the operation')
430+
cancel_token_source.cancel(t('command.code-at-cursor.cancel.user'))
429431
})
430432

431433
progress.report({
432-
message: `sent ${display_token_count(
433-
Math.floor(content.length / 4)
434-
)} tokens...`
434+
message: t('common.progress.waiting-for-server')
435435
})
436436

437437
return await make_api_request({
@@ -440,10 +440,10 @@ const perform_code_at_cursor = async (params: {
440440
body,
441441
cancellation_token: cancel_token_source.token,
442442
on_chunk: () => {
443-
progress.report({ message: 'receiving...' })
443+
progress.report({ message: t('common.progress.receiving') })
444444
},
445445
on_thinking_chunk: () => {
446-
progress.report({ message: 'thinking...' })
446+
progress.report({ message: t('common.progress.thinking') })
447447
}
448448
})
449449
}

‎apps/editor/src/commands/generate-commit-message-command/utils/generate-commit-message-with-api.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import axios from 'axios'
33
import { apply_reasoning_effort } from '@/utils/apply-reasoning-effort'
44
import { dictionary } from '@shared/constants/dictionary'
55
import { make_api_request } from '@/utils/make-api-request'
6-
import { display_token_count } from '@/utils/display-token-count'
76
import { Logger } from '@shared/utils/logger'
87
import { strip_wrapping_quotes } from './strip-wrapping-quotes'
98
import { CommitMessageConfig } from './get-commit-message-config'
@@ -48,9 +47,7 @@ export const generate_commit_message_with_api = async (params: {
4847
})
4948

5049
progress.report({
51-
message: t('common.progress.sent', {
52-
tokens: display_token_count(Math.floor(params.message.length / 4))
53-
})
50+
message: t('common.progress.waiting-for-server')
5451
})
5552

5653
try {
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
export const code_at_cursor = {
2+
'command.code-at-cursor.instructions.placeholder': {
3+
en: 'Enter completion instructions',
4+
pl: 'Wprowadź instrukcje ukończenia',
5+
'zh-cn': '输入补全指令',
6+
ja: '補完の指示を入力してください',
7+
'zh-tw': '輸入補全指令',
8+
de: 'Geben Sie Anweisungen zur Vervollständigung ein',
9+
es: 'Ingrese las instrucciones de autocompletado',
10+
fr: 'Entrez les instructions de complétion',
11+
'pt-br': 'Insira as instruções de preenchimento',
12+
ru: 'Введите инструкции для автодополнения',
13+
ko: '완성 지침을 입력하세요',
14+
it: 'Inserisci le istruzioni di completamento',
15+
tr: 'Tamamlama talimatlarını girin',
16+
cs: 'Zadejte pokyny pro dokončení',
17+
hu: 'Adja meg a kiegészítési utasításokat',
18+
bg: 'Въведете инструкции за довършване'
19+
},
20+
'command.code-at-cursor.instructions.prompt': {
21+
en: 'E.g. "Include explanatory comments".',
22+
pl: 'Np. "Dołącz komentarze wyjaśniające".',
23+
'zh-cn': '例如:"包含解释性注释"。',
24+
ja: '例: 「説明のコメントを含める」',
25+
'zh-tw': '例如:「包含解釋性註釋」。',
26+
de: 'Z.B. "Fügen Sie erklärende Kommentare hinzu".',
27+
es: 'Ej. "Incluir comentarios explicativos".',
28+
fr: 'Ex. "Inclure des commentaires explicatifs".',
29+
'pt-br': 'Ex. "Incluir comentários explicativos".',
30+
ru: 'Напр. "Добавить пояснительные комментарии".',
31+
ko: '예: "설명 주석 포함".',
32+
it: 'Es. "Includi commenti esplicativi".',
33+
tr: 'Örn. "Açıklayıcı yorumlar ekle".',
34+
cs: 'Např. "Zahrnout vysvětlující komentáře".',
35+
hu: 'Pl. "Tartalmazzon magyarázó megjegyzéseket".',
36+
bg: 'Напр. "Включи обяснителни коментари".'
37+
},
38+
'command.code-at-cursor.config.placeholder': {
39+
en: 'Select code at cursor configuration',
40+
pl: 'Wybierz konfigurację kodu w miejscu kursora',
41+
'zh-cn': '选择光标处代码配置',
42+
ja: 'カーソル位置のコード設定を選択',
43+
'zh-tw': '選擇游標處程式碼設定',
44+
de: 'Wählen Sie die Code-at-Cursor-Konfiguration',
45+
es: 'Seleccione la configuración de código en el cursor',
46+
fr: 'Sélectionnez la configuration du code au curseur',
47+
'pt-br': 'Selecione a configuração de código no cursor',
48+
ru: 'Выберите конфигурацию кода под курсором',
49+
ko: '커서 위치의 코드 구성 선택',
50+
it: 'Seleziona la configurazione del codice al cursore',
51+
tr: 'İmleçteki kod yapılandırmasını seçin',
52+
cs: 'Vyberte konfiguraci kódu u kurzoru',
53+
hu: 'Válassza ki a kód a kurzornál konfigurációt',
54+
bg: 'Изберете конфигурация за код при курсора'
55+
},
56+
'command.code-at-cursor.cancel.cursor-moved': {
57+
en: 'User moved the cursor, cancelling request.',
58+
pl: 'Użytkownik przesunął kursor, anulowanie żądania.',
59+
'zh-cn': '用户移动了光标,取消请求。',
60+
ja: 'ユーザーがカーソルを移動したため、リクエストをキャンセルします。',
61+
'zh-tw': '使用者移動了游標,取消請求。',
62+
de: 'Benutzer hat den Cursor bewegt, Anfrage wird abgebrochen.',
63+
es: 'El usuario movió el cursor, cancelando la solicitud.',
64+
fr: "L'utilisateur a déplacé le curseur, annulation de la demande.",
65+
'pt-br': 'O usuário moveu o cursor, cancelando a solicitação.',
66+
ru: 'Пользователь переместил курсор, отмена запроса.',
67+
ko: '사용자가 커서를 이동하여 요청을 취소합니다.',
68+
it: "L'utente ha spostato il cursore, annullamento della richiesta.",
69+
tr: 'Kullanıcı imleci hareket ettirdi, istek iptal ediliyor.',
70+
cs: 'Uživatel pohnul kurzorem, ruším požadavek.',
71+
hu: 'A felhasználó elmozdította a kurzort, kérés megszakítva.',
72+
bg: 'Потребителят премести курсора, отмяна на заявката.'
73+
},
74+
'command.code-at-cursor.progress.title': {
75+
en: 'Requested code at cursor',
76+
pl: 'Zażądano kodu w miejscu kursora',
77+
'zh-cn': '已请求光标处的代码',
78+
ja: 'カーソル位置のコードをリクエストしました',
79+
'zh-tw': '已請求游標處的程式碼',
80+
de: 'Angefragter Code am Cursor',
81+
es: 'Código solicitado en el cursor',
82+
fr: 'Code demandé au curseur',
83+
'pt-br': 'Código solicitado no cursor',
84+
ru: 'Запрошен код под курсором',
85+
ko: '커서 위치에 요청된 코드',
86+
it: 'Codice richiesto al cursore',
87+
tr: 'İmleçteki kod istendi',
88+
cs: 'Vyžádán kód u kurzoru',
89+
hu: 'Kód lekérve a kurzornál',
90+
bg: 'Заявен код при курсора'
91+
},
92+
'command.code-at-cursor.cancel.user': {
93+
en: 'User cancelled the operation',
94+
pl: 'Użytkownik anulował operację',
95+
'zh-cn': '用户取消了操作',
96+
ja: 'ユーザーが操作をキャンセルしました',
97+
'zh-tw': '使用者取消了操作',
98+
de: 'Benutzer hat den Vorgang abgebrochen',
99+
es: 'El usuario canceló la operación',
100+
fr: "L'utilisateur a annulé l'opération",
101+
'pt-br': 'O usuário cancelou a operação',
102+
ru: 'Пользователь отменил операцию',
103+
ko: '사용자가 작업을 취소했습니다',
104+
it: "L'utente ha annullato l'operazione",
105+
tr: 'Kullanıcı işlemi iptal etti',
106+
cs: 'Uživatel zrušil operaci',
107+
hu: 'A felhasználó megszakította a műveletet',
108+
bg: 'Потребителят отмени операцията'
109+
}
110+
} as const
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { checkpoints } from './checkpoints'
22
import { generate_commit_message } from './generate-commit-message'
3+
import { code_at_cursor } from './code-at-cursor'
34

45
export const commands = {
56
...checkpoints,
6-
...generate_commit_message
7+
...generate_commit_message,
8+
...code_at_cursor
79
}

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,23 @@ export const common = {
3535
hu: 'Ugrás a fájlhoz',
3636
bg: 'Отиди на файла'
3737
},
38-
'common.progress.sent': {
39-
en: 'sent {tokens} tokens...',
40-
pl: 'wysłano {tokens} tokenów...',
41-
'zh-cn': '已发送 {tokens} 个 token...',
42-
ja: '{tokens} トークンを送信しました...',
43-
'zh-tw': '已發送 {tokens} 個 token...',
44-
de: '{tokens} Token gesendet...',
45-
es: 'enviados {tokens} tokens...',
46-
fr: '{tokens} jetons envoyés...',
47-
'pt-br': 'enviou {tokens} tokens...',
48-
ru: 'отправлено {tokens} токенов...',
49-
ko: '{tokens} 토큰 보냄...',
50-
it: 'inviati {tokens} token...',
51-
tr: '{tokens} token gönderildi...',
52-
cs: 'odesláno {tokens} tokenů...',
53-
hu: '{tokens} token elküldve...',
54-
bg: 'изпратени {tokens} токена...'
38+
'common.progress.waiting-for-server': {
39+
en: 'waiting for server...',
40+
pl: 'oczekiwanie na serwer...',
41+
'zh-cn': '等待服务器响应...',
42+
ja: 'サーバーを待機中...',
43+
'zh-tw': '等待伺服器回應...',
44+
de: 'Warten auf Server...',
45+
es: 'esperando al servidor...',
46+
fr: 'en attente du serveur...',
47+
'pt-br': 'aguardando o servidor...',
48+
ru: 'ожидание ответа сервера...',
49+
ko: '서버 대기 중...',
50+
it: 'in attesa del server...',
51+
tr: 'sunucu bekleniyor...',
52+
cs: 'čekání na server...',
53+
hu: 'várakozás a szerverre...',
54+
bg: 'изчакване на сървъра...'
5555
},
5656
'common.progress.receiving': {
5757
en: 'receiving...',

0 commit comments

Comments
 (0)