Skip to content

Commit 61849cb

Browse files
committed
refactor(web-ui): i18nize prompt template toast messages
- 移除 ruleAck plugin desc 中的占位符,简化列表显示 - 新增5个模板相关 toast i18n key(zh/en/ja/vi) - 替换 codex-config.mjs 中5处硬编码消息
1 parent bbf3055 commit 61849cb

5 files changed

Lines changed: 73 additions & 16 deletions

File tree

web-ui/modules/app.methods.codex-config.mjs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function createCodexConfigMethods(options = {}) {
6666
const maxLabel = res.maxMessages === 'all' ? 'all' : res.maxMessages;
6767
this.showMessage(`会话导出完成(已截断:最多 ${maxLabel} 条消息)`, 'info');
6868
} else {
69-
this.showMessage('操作成功', 'success');
69+
this.showMessage(this.t('toast.operation.success'), 'success');
7070
}
7171
} catch (e) {
7272
this.showMessage('导出失败', 'error');
@@ -325,7 +325,7 @@ export function createCodexConfigMethods(options = {}) {
325325
if (hasResponseError(res)) {
326326
this.healthCheckResult = null;
327327
if (!silent) {
328-
this.showMessage(getResponseMessage(res, '检查失败'), 'error');
328+
this.showMessage(getResponseMessage(res, this.t('toast.check.fail')), 'error');
329329
}
330330
return;
331331
}
@@ -342,13 +342,13 @@ export function createCodexConfigMethods(options = {}) {
342342
this.healthCheckBatchDone = total;
343343
this.healthCheckBatchFailed = errors + warns;
344344
if (!silent && res.ok) {
345-
this.showMessage('检查通过', 'success');
345+
this.showMessage(this.t('toast.check.success'), 'success');
346346
}
347347
return;
348348
}
349349
this.healthCheckResult = null;
350350
if (!silent) {
351-
this.showMessage('检查失败', 'error');
351+
this.showMessage(this.t('toast.check.fail'), 'error');
352352
}
353353
return;
354354
}
@@ -473,7 +473,7 @@ export function createCodexConfigMethods(options = {}) {
473473
} else {
474474
this.healthCheckResult = null;
475475
if (!silent) {
476-
this.showMessage('检查失败', 'error');
476+
this.showMessage(this.t('toast.check.fail'), 'error');
477477
}
478478
}
479479
} catch (e) {
@@ -561,7 +561,7 @@ export function createCodexConfigMethods(options = {}) {
561561
this.configTemplateContext = 'codex';
562562
this.showConfigTemplateModal = true;
563563
} catch (e) {
564-
this.showMessage('加载模板失败', 'error');
564+
this.showMessage(this.t('toast.template.loadFail'), 'error');
565565
}
566566
},
567567

@@ -797,7 +797,7 @@ export function createCodexConfigMethods(options = {}) {
797797
return;
798798
}
799799
if (!this.configTemplateContent || !this.configTemplateContent.trim()) {
800-
this.showMessage('模板不能为空', 'error');
800+
this.showMessage(this.t('toast.template.empty'), 'error');
801801
return;
802802
}
803803

@@ -822,15 +822,15 @@ export function createCodexConfigMethods(options = {}) {
822822
this.showMessage(res.error, 'error');
823823
return;
824824
}
825-
this.showMessage('模板已应用', 'success');
825+
this.showMessage(this.t('toast.template.applied'), 'success');
826826
this.closeConfigTemplateModal({ force: true });
827827
try {
828828
await this.loadAll();
829829
} catch (_) {
830-
this.showMessage('模板已应用,但界面刷新失败,请手动刷新', 'error');
830+
this.showMessage(this.t('toast.template.appliedButRefreshFail'), 'error');
831831
}
832832
} catch (e) {
833-
this.showMessage('应用模板失败', 'error');
833+
this.showMessage(this.t('toast.template.applyFail'), 'error');
834834
} finally {
835835
this.configTemplateApplying = false;
836836
}

web-ui/modules/i18n/locales/en.mjs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ const en = Object.freeze({
360360
'plugins.builtin.commentPolish.desc': 'Polish the following code comments {{code}}',
361361
'plugins.builtin.commentPolish.line1': 'Polish the following code comments',
362362
'plugins.builtin.ruleAck.name': 'Rule acknowledgement',
363-
'plugins.builtin.ruleAck.desc': 'Please follow 【{{rule}}】, reply when received',
363+
'plugins.builtin.ruleAck.desc': 'Generate rule acknowledgement reply',
364364
'plugins.builtin.ruleAck.line1': 'Please follow 【{{rule}}】, reply when received',
365365

366366
// Toasts
@@ -387,6 +387,18 @@ const en = Object.freeze({
387387
'toast.templates.nameRequired': 'Template name is required',
388388
'toast.templates.builtinNotDuplicable': 'Built-in templates cannot be duplicated',
389389
'toast.templates.builtinNotDeletable': 'Built-in templates cannot be deleted',
390+
'toast.operation.success': 'Operation successful',
391+
'toast.load.fail': 'Failed to load file',
392+
'toast.apply.success': 'Configuration applied',
393+
'toast.apply.fail': 'Failed to apply configuration',
394+
'toast.check.success': 'Check passed',
395+
'toast.check.fail': 'Check failed',
396+
'toast.noChanges': 'No changes detected',
397+
'toast.template.loadFail': 'Failed to load template',
398+
'toast.template.empty': 'Template cannot be empty',
399+
'toast.template.applied': 'Template applied',
400+
'toast.template.appliedButRefreshFail': 'Template applied, but UI refresh failed. Please refresh manually',
401+
'toast.template.applyFail': 'Failed to apply template',
390402
'toast.templates.deleteTitle': 'Delete template',
391403
'toast.templates.deleteMessage': 'Delete “{name}”? This action cannot be undone.',
392404
'toast.templates.deleteConfirm': 'Delete',

web-ui/modules/i18n/locales/ja.mjs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ const ja = Object.freeze({
362362
'plugins.builtin.commentPolish.desc': '以下のコードコメントを軽く整えてください {{code}}',
363363
'plugins.builtin.commentPolish.line1': '以下のコードコメントを軽く整えてください',
364364
'plugins.builtin.ruleAck.name': 'ルール確認返信',
365-
'plugins.builtin.ruleAck.desc': '【{{rule}}】に従って、受信確認を返してください',
365+
'plugins.builtin.ruleAck.desc': 'ルールに従うよう確認返信を指示',
366366
'plugins.builtin.ruleAck.line1': '【{{rule}}】に従って、受信確認を返してください',
367367

368368
// Toasts
@@ -393,6 +393,18 @@ const ja = Object.freeze({
393393
'toast.templates.deleteMessage': '「{name}」を削除しますか?この操作は取り消せません。',
394394
'toast.templates.deleteConfirm': '削除',
395395
'toast.templates.deleteCancel': 'キャンセル',
396+
'toast.operation.success': '操作が成功しました',
397+
'toast.load.fail': 'ファイルの読み込みに失敗しました',
398+
'toast.apply.success': '設定が適用されました',
399+
'toast.apply.fail': '設定の適用に失敗しました',
400+
'toast.check.success': 'チェック成功',
401+
'toast.check.fail': 'チェック失敗',
402+
'toast.noChanges': '変更が検出されませんでした',
403+
'toast.template.loadFail': 'テンプレートの読み込みに失敗しました',
404+
'toast.template.empty': 'テンプレートは空にできません',
405+
'toast.template.applied': 'テンプレートが適用されました',
406+
'toast.template.appliedButRefreshFail': 'テンプレートは適用されましたが、UI の更新に失敗しました。手動で更新してください',
407+
'toast.template.applyFail': 'テンプレートの適用に失敗しました',
396408

397409
// Basic modals
398410
'modal.providerAdd.title': 'プロバイダー追加',

web-ui/modules/i18n/locales/vi.mjs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const vi = Object.freeze({
66
'plugins.builtin.commentPolish.desc': 'Chỉnh nhẹ các chú thích mã sau {{code}}',
77
'plugins.builtin.commentPolish.line1': 'Chỉnh nhẹ các chú thích mã sau',
88
'plugins.builtin.ruleAck.name': 'Xác nhận quy tắc',
9-
'plugins.builtin.ruleAck.desc': 'Hãy làm theo【{{rule}}】, nhận được thì phản hồi',
9+
'plugins.builtin.ruleAck.desc': 'Tạo phản hồi xác nhận quy tắc',
1010
'plugins.builtin.ruleAck.line1': 'Hãy làm theo【{{rule}}】, nhận được thì phản hồi',
1111
// Global
1212
'lang.zh': 'Tiếng Trung',
@@ -235,7 +235,28 @@ const vi = Object.freeze({
235235
'dashboard.doctor.title': 'Doctor',
236236
'dashboard.doctor.runChecks': 'Chạy kiểm tra',
237237
'dashboard.doctor.checking': 'Đang kiểm tra...',
238-
'dashboard.doctor.export': 'Xuất báo cáo'
238+
'dashboard.doctor.export': 'Xuất báo cáo',
239+
240+
// Toasts
241+
'toast.copy.empty': 'Không có gì để sao chép',
242+
'toast.copy.ok': 'Đã sao chép',
243+
'toast.copy.fail': 'Sao chép thất bại',
244+
'toast.save.ok': 'Đã lưu',
245+
'toast.save.fail': 'Lưu thất bại',
246+
'toast.delete.ok': 'Đã xóa',
247+
'toast.delete.fail': 'Xóa thất bại',
248+
'toast.operation.success': 'Thao tác thành công',
249+
'toast.load.fail': 'Tải tệp thất bại',
250+
'toast.apply.success': 'Đã áp dụng cấu hình',
251+
'toast.apply.fail': 'Áp dụng cấu hình thất bại',
252+
'toast.check.success': 'Kiểm tra thành công',
253+
'toast.check.fail': 'Kiểm tra thất bại',
254+
'toast.noChanges': 'Không phát hiện thay đổi',
255+
'toast.template.loadFail': 'Tải mẫu thất bại',
256+
'toast.template.empty': 'Mẫu không được để trống',
257+
'toast.template.applied': 'Đã áp dụng mẫu',
258+
'toast.template.appliedButRefreshFail': 'Đã áp dụng mẫu, nhưng làm mới giao diện thất bại. Vui lòng làm mới thủ công',
259+
'toast.template.applyFail': 'Áp dụng mẫu thất bại'
239260
});
240261

241262
export { vi };

web-ui/modules/i18n/locales/zh.mjs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ const zh = Object.freeze({
360360
'plugins.builtin.commentPolish.desc': '轻微收敛以下代码注释 {{code}}',
361361
'plugins.builtin.commentPolish.line1': '轻微收敛以下代码注释',
362362
'plugins.builtin.ruleAck.name': '规则确认回复',
363-
'plugins.builtin.ruleAck.desc': '请根据【{{rule}}】,收到请回复',
363+
'plugins.builtin.ruleAck.desc': '生成规则确认回复',
364364
'plugins.builtin.ruleAck.line1': '请根据【{{rule}}】,收到请回复',
365365

366366
// Toasts
@@ -388,9 +388,21 @@ const zh = Object.freeze({
388388
'toast.templates.builtinNotDuplicable': '内置模板不可复制',
389389
'toast.templates.builtinNotDeletable': '内置模板不可删除',
390390
'toast.templates.deleteTitle': '删除模板',
391-
'toast.templates.deleteMessage': '删除{name}”?此操作无法撤销。',
391+
'toast.templates.deleteMessage': '删除{name}”?此操作无法撤销。',
392392
'toast.templates.deleteConfirm': '删除',
393393
'toast.templates.deleteCancel': '取消',
394+
'toast.operation.success': '操作成功',
395+
'toast.load.fail': '加载文件失败',
396+
'toast.apply.success': '配置已应用',
397+
'toast.apply.fail': '应用配置失败',
398+
'toast.check.success': '检查通过',
399+
'toast.check.fail': '检查失败',
400+
'toast.noChanges': '未检测到改动',
401+
'toast.template.loadFail': '加载模板失败',
402+
'toast.template.empty': '模板不能为空',
403+
'toast.template.applied': '模板已应用',
404+
'toast.template.appliedButRefreshFail': '模板已应用,但界面刷新失败,请手动刷新',
405+
'toast.template.applyFail': '应用模板失败',
394406

395407
// Basic modals
396408
'modal.providerAdd.title': '添加提供商',

0 commit comments

Comments
 (0)