dsh-agy-link 0.6.53 → 0.6.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.54 (2026-11-21)
4
+
5
+ ### English
6
+
7
+ - **Fix(client): the rest of the DOM surfaces now speak the host language (fixes #153, part 2).** Part 1 localized the decision chips; this one covers the image chips and their toasts, the whole image lightbox (tooltips, button labels, loading and keyboard hints), the mermaid view-source toggle and parse warning, the compaction card title, and the question-card insert/recorded labels.
8
+ - **New `src/client/i18n-bridge.ts`**: these modules are plain DOM enhancers, not React components, and several have no `ctx` of their own (the lightbox is opened by the scanner). They now read one translator bound once in `index.ts`, with `translateOr(key, englishFallback)` guaranteeing copy instead of a bare key when no locale service exists. `decisions.ts` was migrated onto it, deleting its private copy of the same fallback logic.
9
+ - **`mermaid` keeps one Chinese literal on purpose**: `代码块` is DSH's own placeholder banner text, matched to DETECT "this banner carries no real language label". Translating it would break the detection.
10
+ - **`compaction` no longer reads `document.documentElement.lang`**: that is DSH's page language, not this plugin's locale, and the two can disagree — the binding is the authority now.
11
+ - **Test(dx): hardened two timing guards in `test/proxy-keychain.test.ts`.** They measured machine load rather than the watchdog: a starved event loop on a busy host made a 5s guard fire before a 400ms timeout could settle, and one escalation test hung to the runner's 60s default. The guards are widened and now reap the child on overrun, while the assertions that bound the actual tick are unchanged.
12
+
13
+ ### 中文
14
+
15
+ - **修复(客户端):其余 DOM 界面也改用宿主语言(修复 #153 第二部分)。** 第一部分本地化了决策芯片;本次覆盖图片 chip 与其 toast、整个图片灯箱(tooltip、按钮文字、加载与键盘提示)、mermaid 的「查看源码」切换与解析失败警告、压缩卡片标题,以及问题卡片的填入/已记录文案。
16
+ - **新增 `src/client/i18n-bridge.ts`**:这些模块是纯 DOM 增强器而非 React 组件,其中几个根本没有自己的 `ctx`(灯箱由 scanner 打开)。它们现在统一读取在 `index.ts` 一次性绑定的 translator,`translateOr(key, 英文兜底)` 保证没有 locale 服务时输出文案而不是裸 key。`decisions.ts` 已迁移过来,删掉了它自己那份重复的兜底逻辑。
17
+ - **`mermaid` 刻意保留一处中文**:`代码块` 是 DSH 自己的占位 banner 文本,用来**识别**「该 banner 没有真实语言标签」。翻译它会破坏这段判断。
18
+ - **`compaction` 不再读 `document.documentElement.lang`**:那是 DSH 的页面语言,不是本插件的 locale,两者可能不一致——现在以 locale 绑定为准。
19
+ - **测试(开发体验):加固 `test/proxy-keychain.test.ts` 的两处时序守卫。** 它们实际在测机器负载而非看门狗:繁忙宿主上被饿死的事件循环会让 5 秒守卫早于 400ms 超时结算,另有一条升级用例会一直挂到 runner 的 60 秒默认超时。守卫已放宽,并在超时时主动回收子进程;约束真实 tick 的断言保持不变。
20
+
3
21
  ## 0.6.53 (2026-11-21)
4
22
 
5
23
  ### English
package/dist/client.js CHANGED
@@ -55,6 +55,50 @@ window.__ModuleLoader__.load({
55
55
  "decision.quickFill": "💬 点击选项快速填入:",
56
56
  "decision.insertTooltip": "点击填入: {text}",
57
57
  "decision.insertPayload": "我选择 {choice}",
58
+ "image.zoomHint": "{alt}(点击全屏放大)",
59
+ "image.previewTitle": "预览图片({name})",
60
+ "image.previewChip": "预览",
61
+ "image.playTitle": "播放视频({name})",
62
+ "image.playChip": "播放",
63
+ "file.openedInSidebar": "已在原生边栏打开:{name}",
64
+ "file.openedInSystem": "已在系统程序中打开:{name}",
65
+ "file.openFailed": "打开失败:{error}",
66
+ "file.notFound": "未找到文件",
67
+ "lightbox.zoomIn": "放大",
68
+ "lightbox.zoomOut": "缩小",
69
+ "lightbox.reset": "实际大小(1:1)",
70
+ "lightbox.openWithApp": "用系统默认应用打开",
71
+ "lightbox.reveal": "在访达 / 资源管理器中显示",
72
+ "lightbox.copyPath": "复制完整文件路径",
73
+ "lightbox.close": "关闭(ESC)",
74
+ "lightbox.unavailableTitle": "无法直接预览媒体",
75
+ "lightbox.unavailableHint": "文件可能正在生成中、已移动或格式需由外部应用呈现。",
76
+ "lightbox.revealAction": "在访达/资源管理器中查找",
77
+ "lightbox.revealed": "已在文件管理器中定位",
78
+ "lightbox.revealFailed": "无法定位文件",
79
+ "lightbox.revealFailedDetail": "定位失败:{error}",
80
+ "lightbox.openedInApp": "已在系统应用中打开",
81
+ "lightbox.openFailed": "打开失败:{error}",
82
+ "lightbox.unknownError": "未知错误",
83
+ "lightbox.pathCopied": "文件路径已复制到剪贴板",
84
+ "lightbox.hintClose": "ESC 退出 · 点击空白处关闭",
85
+ "lightbox.hintZoom": "ESC 退出 · 滚轮缩放 · 拖拽平移",
86
+ "lightbox.loading": "加载媒体中…",
87
+ "lightbox.zoomInChip": "放大",
88
+ "lightbox.zoomOutChip": "缩小",
89
+ "lightbox.openChip": "打开",
90
+ "lightbox.revealChip": "定位",
91
+ "lightbox.copyChip": "复制路径",
92
+ "lightbox.copiedChip": "✓ 已复制",
93
+ "lightbox.closeChip": "关闭",
94
+ "mermaid.viewSource": "查看源码",
95
+ "mermaid.viewDiagram": "查看图表",
96
+ "mermaid.toggle": "切换图表与原始代码",
97
+ "mermaid.parseFailed": "⚠️ Mermaid 图表解析失败,已保留原始代码呈现",
98
+ "compaction.contextCompacted": "上下文已压缩",
99
+ "question.insert": "💬 填入对话框",
100
+ "question.inserted": "✓ 已填入对话框",
101
+ "question.recorded": "已记录:{value}",
58
102
  "account.proxyPlaceholder": "专属代理 URL(如 http://127.0.0.1:7890,留空则继承全局)",
59
103
  "account.aliasPlaceholder": "账号别名(例如:备用账号 2)",
60
104
  "account.removeTitle": "移除此账号",
@@ -293,6 +337,50 @@ window.__ModuleLoader__.load({
293
337
  "decision.quickFill": "💬 Click an option to fill it in:",
294
338
  "decision.insertTooltip": "Insert: {text}",
295
339
  "decision.insertPayload": "I choose {choice}",
340
+ "image.zoomHint": "{alt} (click to view full screen)",
341
+ "image.previewTitle": "Preview ({name})",
342
+ "image.previewChip": "Preview",
343
+ "image.playTitle": "Play video ({name})",
344
+ "image.playChip": "Play",
345
+ "file.openedInSidebar": "Opened in the sidebar: {name}",
346
+ "file.openedInSystem": "Opened in the system app: {name}",
347
+ "file.openFailed": "Could not open: {error}",
348
+ "file.notFound": "file not found",
349
+ "lightbox.zoomIn": "Zoom in",
350
+ "lightbox.zoomOut": "Zoom out",
351
+ "lightbox.reset": "Actual size (1:1)",
352
+ "lightbox.openWithApp": "Open with the default app",
353
+ "lightbox.reveal": "Reveal in the file manager",
354
+ "lightbox.copyPath": "Copy the full file path",
355
+ "lightbox.close": "Close (ESC)",
356
+ "lightbox.unavailableTitle": "Preview unavailable",
357
+ "lightbox.unavailableHint": "The file may still be generating, may have moved, or needs an external app.",
358
+ "lightbox.revealAction": "Reveal in the file manager",
359
+ "lightbox.revealed": "Revealed in the file manager",
360
+ "lightbox.revealFailed": "Could not locate the file",
361
+ "lightbox.revealFailedDetail": "Could not reveal: {error}",
362
+ "lightbox.openedInApp": "Opened in the system app",
363
+ "lightbox.openFailed": "Could not open: {error}",
364
+ "lightbox.unknownError": "unknown error",
365
+ "lightbox.pathCopied": "File path copied to the clipboard",
366
+ "lightbox.hintClose": "ESC to exit · click the backdrop to close",
367
+ "lightbox.hintZoom": "ESC to exit · scroll to zoom · drag to pan",
368
+ "lightbox.loading": "Loading media…",
369
+ "lightbox.zoomInChip": "Zoom in",
370
+ "lightbox.zoomOutChip": "Zoom out",
371
+ "lightbox.openChip": "Open",
372
+ "lightbox.revealChip": "Reveal",
373
+ "lightbox.copyChip": "Copy path",
374
+ "lightbox.copiedChip": "✓ Copied",
375
+ "lightbox.closeChip": "Close",
376
+ "mermaid.viewSource": "View source",
377
+ "mermaid.viewDiagram": "View diagram",
378
+ "mermaid.toggle": "Switch between the diagram and its source",
379
+ "mermaid.parseFailed": "⚠️ This Mermaid diagram could not be rendered; the source is kept below.",
380
+ "compaction.contextCompacted": "Context compacted",
381
+ "question.insert": "💬 Insert into the chat",
382
+ "question.inserted": "✓ Inserted into the chat",
383
+ "question.recorded": "Recorded: {value}",
296
384
  "account.proxyPlaceholder": "Dedicated proxy URL (e.g. http://127.0.0.1:7890; leave blank to inherit global)",
297
385
  "account.aliasPlaceholder": "Account alias (for example: Backup account 2)",
298
386
  "account.removeTitle": "Remove this account",
@@ -531,6 +619,50 @@ window.__ModuleLoader__.load({
531
619
  "decision.quickFill": "💬 Clique numa opção para preenchê-la:",
532
620
  "decision.insertTooltip": "Inserir: {text}",
533
621
  "decision.insertPayload": "Escolho {choice}",
622
+ "image.zoomHint": "{alt} (clique para ver em tela cheia)",
623
+ "image.previewTitle": "Pré-visualizar ({name})",
624
+ "image.previewChip": "Ver",
625
+ "image.playTitle": "Reproduzir vídeo ({name})",
626
+ "image.playChip": "Reproduzir",
627
+ "file.openedInSidebar": "Aberto na barra lateral: {name}",
628
+ "file.openedInSystem": "Aberto no app do sistema: {name}",
629
+ "file.openFailed": "Não foi possível abrir: {error}",
630
+ "file.notFound": "arquivo não encontrado",
631
+ "lightbox.zoomIn": "Ampliar",
632
+ "lightbox.zoomOut": "Reduzir",
633
+ "lightbox.reset": "Tamanho real (1:1)",
634
+ "lightbox.openWithApp": "Abrir com o app padrão",
635
+ "lightbox.reveal": "Mostrar no gerenciador de arquivos",
636
+ "lightbox.copyPath": "Copiar o caminho completo",
637
+ "lightbox.close": "Fechar (ESC)",
638
+ "lightbox.unavailableTitle": "Pré-visualização indisponível",
639
+ "lightbox.unavailableHint": "O arquivo pode estar sendo gerado, ter sido movido ou precisar de um app externo.",
640
+ "lightbox.revealAction": "Mostrar no gerenciador de arquivos",
641
+ "lightbox.revealed": "Mostrado no gerenciador de arquivos",
642
+ "lightbox.revealFailed": "Não foi possível localizar o arquivo",
643
+ "lightbox.revealFailedDetail": "Não foi possível mostrar: {error}",
644
+ "lightbox.openedInApp": "Aberto no app do sistema",
645
+ "lightbox.openFailed": "Não foi possível abrir: {error}",
646
+ "lightbox.unknownError": "erro desconhecido",
647
+ "lightbox.pathCopied": "Caminho copiado para a área de transferência",
648
+ "lightbox.hintClose": "ESC para sair · clique no fundo para fechar",
649
+ "lightbox.hintZoom": "ESC para sair · rolagem para zoom · arraste para mover",
650
+ "lightbox.loading": "Carregando mídia…",
651
+ "lightbox.zoomInChip": "Ampliar",
652
+ "lightbox.zoomOutChip": "Reduzir",
653
+ "lightbox.openChip": "Abrir",
654
+ "lightbox.revealChip": "Mostrar",
655
+ "lightbox.copyChip": "Copiar caminho",
656
+ "lightbox.copiedChip": "✓ Copiado",
657
+ "lightbox.closeChip": "Fechar",
658
+ "mermaid.viewSource": "Ver código",
659
+ "mermaid.viewDiagram": "Ver diagrama",
660
+ "mermaid.toggle": "Alternar entre o diagrama e o código",
661
+ "mermaid.parseFailed": "⚠️ Não foi possível renderizar este diagrama Mermaid; o código foi mantido abaixo.",
662
+ "compaction.contextCompacted": "Contexto compactado",
663
+ "question.insert": "💬 Inserir no chat",
664
+ "question.inserted": "✓ Inserido no chat",
665
+ "question.recorded": "Registrado: {value}",
534
666
  "account.proxyPlaceholder": "URL de proxy dedicada (ex.: http://127.0.0.1:7890; deixe vazio para herdar a global)",
535
667
  "account.aliasPlaceholder": "Apelido da conta (por exemplo: Conta reserva 2)",
536
668
  "account.removeTitle": "Remover esta conta",
@@ -769,6 +901,50 @@ window.__ModuleLoader__.load({
769
901
  "decision.quickFill": "💬 Haz clic en una opción para rellenarla:",
770
902
  "decision.insertTooltip": "Insertar: {text}",
771
903
  "decision.insertPayload": "Elijo {choice}",
904
+ "image.zoomHint": "{alt} (clic para ver a pantalla completa)",
905
+ "image.previewTitle": "Vista previa ({name})",
906
+ "image.previewChip": "Ver",
907
+ "image.playTitle": "Reproducir vídeo ({name})",
908
+ "image.playChip": "Reproducir",
909
+ "file.openedInSidebar": "Abierto en la barra lateral: {name}",
910
+ "file.openedInSystem": "Abierto en la app del sistema: {name}",
911
+ "file.openFailed": "No se pudo abrir: {error}",
912
+ "file.notFound": "archivo no encontrado",
913
+ "lightbox.zoomIn": "Acercar",
914
+ "lightbox.zoomOut": "Alejar",
915
+ "lightbox.reset": "Tamaño real (1:1)",
916
+ "lightbox.openWithApp": "Abrir con la app predeterminada",
917
+ "lightbox.reveal": "Mostrar en el gestor de archivos",
918
+ "lightbox.copyPath": "Copiar la ruta completa",
919
+ "lightbox.close": "Cerrar (ESC)",
920
+ "lightbox.unavailableTitle": "Vista previa no disponible",
921
+ "lightbox.unavailableHint": "El archivo puede estar generándose, haberse movido o necesitar una app externa.",
922
+ "lightbox.revealAction": "Mostrar en el gestor de archivos",
923
+ "lightbox.revealed": "Mostrado en el gestor de archivos",
924
+ "lightbox.revealFailed": "No se pudo localizar el archivo",
925
+ "lightbox.revealFailedDetail": "No se pudo mostrar: {error}",
926
+ "lightbox.openedInApp": "Abierto en la app del sistema",
927
+ "lightbox.openFailed": "No se pudo abrir: {error}",
928
+ "lightbox.unknownError": "error desconocido",
929
+ "lightbox.pathCopied": "Ruta copiada al portapapeles",
930
+ "lightbox.hintClose": "ESC para salir · clic en el fondo para cerrar",
931
+ "lightbox.hintZoom": "ESC para salir · rueda para zoom · arrastrar para mover",
932
+ "lightbox.loading": "Cargando contenido…",
933
+ "lightbox.zoomInChip": "Acercar",
934
+ "lightbox.zoomOutChip": "Alejar",
935
+ "lightbox.openChip": "Abrir",
936
+ "lightbox.revealChip": "Mostrar",
937
+ "lightbox.copyChip": "Copiar ruta",
938
+ "lightbox.copiedChip": "✓ Copiado",
939
+ "lightbox.closeChip": "Cerrar",
940
+ "mermaid.viewSource": "Ver código",
941
+ "mermaid.viewDiagram": "Ver diagrama",
942
+ "mermaid.toggle": "Alternar entre el diagrama y su código",
943
+ "mermaid.parseFailed": "⚠️ No se pudo renderizar este diagrama Mermaid; el código se mantiene abajo.",
944
+ "compaction.contextCompacted": "Contexto compactado",
945
+ "question.insert": "💬 Insertar en el chat",
946
+ "question.inserted": "✓ Insertado en el chat",
947
+ "question.recorded": "Registrado: {value}",
772
948
  "account.proxyPlaceholder": "URL de proxy dedicada (p. ej., http://127.0.0.1:7890; déjalo vacío para heredar la global)",
773
949
  "account.aliasPlaceholder": "Alias de la cuenta (por ejemplo: Cuenta de respaldo 2)",
774
950
  "account.removeTitle": "Eliminar esta cuenta",
@@ -1841,6 +2017,37 @@ window.__ModuleLoader__.load({
1841
2017
  overlaySuspendRefs = 0;
1842
2018
  }
1843
2019
  //#endregion
2020
+ //#region src/client/i18n-bridge.ts
2021
+ /** Fill `{name}` placeholders in a template. */
2022
+ function fillTemplate(template, params) {
2023
+ return template.replace(/\{(\w+)\}/g, (_, name) => String(params?.[name] ?? ""));
2024
+ }
2025
+ let active = null;
2026
+ /**
2027
+ * Bind the plugin's locale service. Safe to call more than once (a plugin
2028
+ * reload replaces the binding), and tolerant of a host without `locale`.
2029
+ */
2030
+ function bindTranslator(ctx) {
2031
+ try {
2032
+ const bound = (ctx?.locale)?.bind?.(NS);
2033
+ active = typeof bound === "function" ? bound : null;
2034
+ } catch {
2035
+ active = null;
2036
+ }
2037
+ }
2038
+ /**
2039
+ * Translate a key, falling back to `fallback` (English) when no locale service is
2040
+ * bound or the key is missing. The fallback is the source of truth for copy that
2041
+ * must never render as a bare key.
2042
+ */
2043
+ function translateOr(key, fallback, params) {
2044
+ if (active !== null) try {
2045
+ const value = active(key, params);
2046
+ if (typeof value === "string" && value !== "" && value !== key) return value;
2047
+ } catch {}
2048
+ return fillTemplate(fallback, params);
2049
+ }
2050
+ //#endregion
1844
2051
  //#region src/common/timeouts.ts
1845
2052
  /** Status poll: keep the console responsive, never stack polls. */
1846
2053
  const STATUS_TIMEOUT_MS = 5e3;
@@ -2412,23 +2619,23 @@ window.__ModuleLoader__.load({
2412
2619
  if (!isVideo) {
2413
2620
  const btnZoomIn = document.createElement("button");
2414
2621
  btnZoomIn.className = "agy-lightbox-btn";
2415
- btnZoomIn.title = "放大 / Zoom In";
2416
- btnZoomIn.innerHTML = "<span class=\"agy-lightbox-btn-icon\"><svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"11\" cy=\"11\" r=\"8\"></circle><line x1=\"21\" y1=\"21\" x2=\"16.65\" y2=\"16.65\"></line><line x1=\"11\" y1=\"8\" x2=\"11\" y2=\"14\"></line><line x1=\"8\" y1=\"11\" x2=\"14\" y2=\"11\"></line></svg></span><span class=\"agy-btn-text\">放大</span><span style=\"display:none\">🔍+</span>";
2622
+ btnZoomIn.title = translateOr("lightbox.zoomIn", "Zoom in");
2623
+ btnZoomIn.innerHTML = "<span class=\"agy-lightbox-btn-icon\"><svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"11\" cy=\"11\" r=\"8\"></circle><line x1=\"21\" y1=\"21\" x2=\"16.65\" y2=\"16.65\"></line><line x1=\"11\" y1=\"8\" x2=\"11\" y2=\"14\"></line><line x1=\"8\" y1=\"11\" x2=\"14\" y2=\"11\"></line></svg></span><span class=\"agy-btn-text\">" + translateOr("lightbox.zoomInChip", "Zoom in") + "</span><span style=\"display:none\">🔍+</span>";
2417
2624
  btnZoomIn.onclick = (e) => {
2418
2625
  e.stopPropagation();
2419
2626
  callbacks.onZoomIn();
2420
2627
  };
2421
2628
  const btnZoomOut = document.createElement("button");
2422
2629
  btnZoomOut.className = "agy-lightbox-btn";
2423
- btnZoomOut.title = "缩小 / Zoom Out";
2424
- btnZoomOut.innerHTML = "<span class=\"agy-lightbox-btn-icon\"><svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"11\" cy=\"11\" r=\"8\"></circle><line x1=\"21\" y1=\"21\" x2=\"16.65\" y2=\"16.65\"></line><line x1=\"8\" y1=\"11\" x2=\"14\" y2=\"11\"></line></svg></span><span class=\"agy-btn-text\">缩小</span><span style=\"display:none\">🔍-</span>";
2630
+ btnZoomOut.title = translateOr("lightbox.zoomOut", "Zoom out");
2631
+ btnZoomOut.innerHTML = "<span class=\"agy-lightbox-btn-icon\"><svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"11\" cy=\"11\" r=\"8\"></circle><line x1=\"21\" y1=\"21\" x2=\"16.65\" y2=\"16.65\"></line><line x1=\"8\" y1=\"11\" x2=\"14\" y2=\"11\"></line></svg></span><span class=\"agy-btn-text\">" + translateOr("lightbox.zoomOutChip", "Zoom out") + "</span><span style=\"display:none\">🔍-</span>";
2425
2632
  btnZoomOut.onclick = (e) => {
2426
2633
  e.stopPropagation();
2427
2634
  callbacks.onZoomOut();
2428
2635
  };
2429
2636
  const btnReset = document.createElement("button");
2430
2637
  btnReset.className = "agy-lightbox-btn";
2431
- btnReset.title = "实际大小 / Reset (1:1)";
2638
+ btnReset.title = translateOr("lightbox.reset", "Actual size (1:1)");
2432
2639
  btnReset.innerHTML = "<span class=\"agy-lightbox-btn-icon\"><svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3\"></path></svg></span><span class=\"agy-btn-text\">1:1</span>";
2433
2640
  btnReset.onclick = (e) => {
2434
2641
  e.stopPropagation();
@@ -2441,37 +2648,37 @@ window.__ModuleLoader__.load({
2441
2648
  if (rawPath) {
2442
2649
  const btnOpen = document.createElement("button");
2443
2650
  btnOpen.className = "agy-lightbox-btn";
2444
- btnOpen.title = "用系统默认应用打开 / Open with default app";
2445
- btnOpen.innerHTML = "<span class=\"agy-lightbox-btn-icon\"><svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\"></path><polyline points=\"15 3 21 3 21 9\"></polyline><line x1=\"10\" y1=\"14\" x2=\"21\" y2=\"3\"></line></svg></span><span class=\"agy-btn-text\">打开</span>";
2651
+ btnOpen.title = translateOr("lightbox.openWithApp", "Open with the default app");
2652
+ btnOpen.innerHTML = "<span class=\"agy-lightbox-btn-icon\"><svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\"></path><polyline points=\"15 3 21 3 21 9\"></polyline><line x1=\"10\" y1=\"14\" x2=\"21\" y2=\"3\"></line></svg></span><span class=\"agy-btn-text\">" + translateOr("lightbox.openChip", "Open") + "</span>";
2446
2653
  btnOpen.onclick = (e) => {
2447
2654
  e.stopPropagation();
2448
2655
  openInSystem(rawPath, false).then((res) => {
2449
- showToast(res.ok ? "已在系统应用中打开" : `打开失败: ${res.error || "未知错误"}`);
2656
+ showToast(res.ok ? translateOr("lightbox.openedInApp", "Opened in the system app") : translateOr("lightbox.openFailed", "Could not open: {error}", { error: res.error || translateOr("lightbox.unknownError", "unknown error") }));
2450
2657
  });
2451
2658
  };
2452
2659
  actions.appendChild(btnOpen);
2453
2660
  const btnReveal = document.createElement("button");
2454
2661
  btnReveal.className = "agy-lightbox-btn";
2455
- btnReveal.title = "在访达 / 资源管理器中显示 (Reveal in File Manager)";
2456
- btnReveal.innerHTML = "<span class=\"agy-lightbox-btn-icon\"><svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z\"></path></svg></span><span class=\"agy-btn-text\">定位</span>";
2662
+ btnReveal.title = translateOr("lightbox.reveal", "Reveal in the file manager");
2663
+ btnReveal.innerHTML = "<span class=\"agy-lightbox-btn-icon\"><svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z\"></path></svg></span><span class=\"agy-btn-text\">" + translateOr("lightbox.revealChip", "Reveal") + "</span>";
2457
2664
  btnReveal.onclick = (e) => {
2458
2665
  e.stopPropagation();
2459
2666
  openInSystem(rawPath, true).then((res) => {
2460
- showToast(res.ok ? "已在文件管理器中定位" : `定位失败: ${res.error || "未知错误"}`);
2667
+ showToast(res.ok ? translateOr("lightbox.revealed", "Revealed in the file manager") : translateOr("lightbox.revealFailedDetail", "Could not reveal: {error}", { error: res.error || translateOr("lightbox.unknownError", "unknown error") }));
2461
2668
  });
2462
2669
  };
2463
2670
  actions.appendChild(btnReveal);
2464
2671
  const btnCopyPath = document.createElement("button");
2465
2672
  btnCopyPath.className = "agy-lightbox-btn";
2466
- btnCopyPath.title = "复制完整文件路径";
2467
- btnCopyPath.innerHTML = "<span class=\"agy-lightbox-btn-icon\"><svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" ry=\"2\"></rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"></path></svg></span><span class=\"agy-btn-text\">复制路径</span>";
2673
+ btnCopyPath.title = translateOr("lightbox.copyPath", "Copy the full file path");
2674
+ btnCopyPath.innerHTML = "<span class=\"agy-lightbox-btn-icon\"><svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" ry=\"2\"></rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"></path></svg></span><span class=\"agy-btn-text\">" + translateOr("lightbox.copyChip", "Copy path") + "</span>";
2468
2675
  btnCopyPath.onclick = (e) => {
2469
2676
  e.stopPropagation();
2470
2677
  if (navigator.clipboard) navigator.clipboard.writeText(rawPath).then(() => {
2471
- showToast("文件路径已复制到剪贴板");
2472
- btnCopyPath.innerHTML = "<span class=\"agy-btn-text\">✓ 已复制</span>";
2678
+ showToast(translateOr("lightbox.pathCopied", "File path copied to the clipboard"));
2679
+ btnCopyPath.innerHTML = "<span class=\"agy-btn-text\">" + translateOr("lightbox.copiedChip", "✓ Copied") + "</span>";
2473
2680
  setTimeout(() => {
2474
- btnCopyPath.innerHTML = "<span class=\"agy-lightbox-btn-icon\"><svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" ry=\"2\"></rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"></path></svg></span><span class=\"agy-btn-text\">复制路径</span>";
2681
+ btnCopyPath.innerHTML = "<span class=\"agy-lightbox-btn-icon\"><svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" ry=\"2\"></rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"></path></svg></span><span class=\"agy-btn-text\">" + translateOr("lightbox.copyChip", "Copy path") + "</span>";
2475
2682
  }, 1500);
2476
2683
  }).catch(() => {});
2477
2684
  };
@@ -2482,8 +2689,8 @@ window.__ModuleLoader__.load({
2482
2689
  actions.appendChild(divider);
2483
2690
  const btnClose = document.createElement("button");
2484
2691
  btnClose.className = "agy-lightbox-btn agy-lightbox-btn-close";
2485
- btnClose.title = "关闭 (ESC)";
2486
- btnClose.innerHTML = "<span class=\"agy-lightbox-btn-icon\"><svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line></svg></span><span class=\"agy-btn-text\">关闭</span><span style=\"display:none\">✕ 关闭</span>";
2692
+ btnClose.title = translateOr("lightbox.close", "Close (ESC)");
2693
+ btnClose.innerHTML = "<span class=\"agy-lightbox-btn-icon\"><svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line></svg></span><span class=\"agy-btn-text\">" + translateOr("lightbox.closeChip", "Close") + "</span><span style=\"display:none\">✕ " + translateOr("lightbox.closeChip", "Close") + "</span>";
2487
2694
  btnClose.onclick = (e) => {
2488
2695
  e.stopPropagation();
2489
2696
  callbacks.onClose();
@@ -2500,13 +2707,13 @@ window.__ModuleLoader__.load({
2500
2707
  errorIcon.innerHTML = "<svg width=\"36\" height=\"36\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#f87171\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"></circle><line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"12\"></line><line x1=\"12\" y1=\"16\" x2=\"12.01\" y2=\"16\"></line></svg>";
2501
2708
  const errorTitle = document.createElement("div");
2502
2709
  errorTitle.className = "agy-lightbox-error-title";
2503
- errorTitle.textContent = "无法直接预览媒体 / Media Preview Unavailable";
2710
+ errorTitle.textContent = translateOr("lightbox.unavailableTitle", "Preview unavailable");
2504
2711
  const errorDesc = document.createElement("div");
2505
2712
  errorDesc.className = "agy-lightbox-error-desc";
2506
2713
  errorDesc.textContent = rawPath || src;
2507
2714
  const errorHint = document.createElement("div");
2508
2715
  errorHint.className = "agy-lightbox-error-hint";
2509
- errorHint.textContent = "文件可能正在生成中、已移动或格式需由外部应用呈现。";
2716
+ errorHint.textContent = translateOr("lightbox.unavailableHint", "The file may still be generating, may have moved, or needs an external app.");
2510
2717
  errorCard.appendChild(errorIcon);
2511
2718
  errorCard.appendChild(errorTitle);
2512
2719
  errorCard.appendChild(errorDesc);
@@ -2516,10 +2723,10 @@ window.__ModuleLoader__.load({
2516
2723
  btnRow.style.cssText = "display:flex;gap:8px;margin-top:14px;";
2517
2724
  const btnOpen = document.createElement("button");
2518
2725
  btnOpen.className = "agy-lightbox-btn";
2519
- btnOpen.textContent = "在访达/资源管理器中查找";
2726
+ btnOpen.textContent = translateOr("lightbox.revealAction", "Reveal in the file manager");
2520
2727
  btnOpen.onclick = () => {
2521
2728
  openInSystem(rawPath, true).then((r) => {
2522
- showToast(r.ok ? "已在文件管理器中定位" : "无法定位文件");
2729
+ showToast(r.ok ? translateOr("lightbox.revealed", "Revealed in the file manager") : translateOr("lightbox.revealFailed", "Could not locate the file"));
2523
2730
  });
2524
2731
  };
2525
2732
  btnRow.appendChild(btnOpen);
@@ -2597,7 +2804,7 @@ window.__ModuleLoader__.load({
2597
2804
  overlay.appendChild(header);
2598
2805
  const spinner = document.createElement("div");
2599
2806
  spinner.className = "agy-lightbox-spinner";
2600
- spinner.innerHTML = "<div class=\"agy-lightbox-spinner-ring\"></div><div class=\"agy-lightbox-spinner-text\">加载媒体中...</div>";
2807
+ spinner.innerHTML = "<div class=\"agy-lightbox-spinner-ring\"></div><div class=\"agy-lightbox-spinner-text\">" + translateOr("lightbox.loading", "Loading media…") + "</div>";
2601
2808
  const errorCard = buildErrorCard(rawPath, src);
2602
2809
  if (isVideo) {
2603
2810
  const video = document.createElement("video");
@@ -2642,7 +2849,7 @@ window.__ModuleLoader__.load({
2642
2849
  body.appendChild(imgWrap);
2643
2850
  const hints = document.createElement("div");
2644
2851
  hints.className = "agy-lightbox-hints";
2645
- hints.textContent = isVideo ? "ESC 退出 · 点击空白处关闭" : "ESC 退出 · 滚轮缩放 · 拖拽平移";
2852
+ hints.textContent = isVideo ? translateOr("lightbox.hintClose", "ESC to exit · click the backdrop to close") : translateOr("lightbox.hintZoom", "ESC to exit · scroll to zoom · drag to pan");
2646
2853
  overlay.appendChild(hints);
2647
2854
  overlay.appendChild(body);
2648
2855
  overlay.onclick = (e) => {
@@ -2923,7 +3130,7 @@ window.__ModuleLoader__.load({
2923
3130
  card.className = "agy-image-card";
2924
3131
  const thumbWrap = document.createElement("div");
2925
3132
  thumbWrap.className = "agy-image-thumb-wrap";
2926
- thumbWrap.title = `${altText || "Image"} (点击全屏放大)`;
3133
+ thumbWrap.title = translateOr("image.zoomHint", "{alt} (click to view full screen)", { alt: altText || "Image" });
2927
3134
  const img = document.createElement("img");
2928
3135
  img.className = "agy-image-thumb";
2929
3136
  img.src = mediaUrl;
@@ -2966,8 +3173,8 @@ window.__ModuleLoader__.load({
2966
3173
  badge.className = "agy-image-link-chip agy-image-link-icon";
2967
3174
  badge.setAttribute("role", "button");
2968
3175
  badge.setAttribute("tabindex", "0");
2969
- badge.title = `预览图片 / Preview (${linkText})`;
2970
- badge.innerHTML = "<span class=\"agy-image-chip-icon\"><svg width=\"12\" height=\"12\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"vertical-align:-1px;display:inline-block;\"><path d=\"M1 8s3-5.5 7-5.5S15 8 15 8s-3 5.5-7 5.5S1 8 1 8z\"/><circle cx=\"8\" cy=\"8\" r=\"2.5\"/></svg></span><span class=\"agy-image-chip-text\">预览</span>";
3176
+ badge.title = translateOr("image.previewTitle", "Preview ({name})", { name: linkText });
3177
+ badge.innerHTML = "<span class=\"agy-image-chip-icon\"><svg width=\"12\" height=\"12\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"vertical-align:-1px;display:inline-block;\"><path d=\"M1 8s3-5.5 7-5.5S15 8 15 8s-3 5.5-7 5.5S1 8 1 8z\"/><circle cx=\"8\" cy=\"8\" r=\"2.5\"/></svg></span><span class=\"agy-image-chip-text\">" + translateOr("image.previewChip", "Preview") + "</span>";
2971
3178
  badge.onclick = (e) => {
2972
3179
  e.preventDefault();
2973
3180
  e.stopPropagation();
@@ -2999,8 +3206,8 @@ window.__ModuleLoader__.load({
2999
3206
  badge.className = "agy-image-link-chip agy-chip-video agy-video-link-icon";
3000
3207
  badge.setAttribute("role", "button");
3001
3208
  badge.setAttribute("tabindex", "0");
3002
- badge.title = `播放视频 / Play Video (${linkText})`;
3003
- badge.innerHTML = "<span class=\"agy-image-chip-icon\"><svg width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><polygon points=\"5 3 19 12 5 21 5 3\"></polygon></svg></span><span class=\"agy-image-chip-text\">播放</span>";
3209
+ badge.title = translateOr("image.playTitle", "Play video ({name})", { name: linkText });
3210
+ badge.innerHTML = "<span class=\"agy-image-chip-icon\"><svg width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><polygon points=\"5 3 19 12 5 21 5 3\"></polygon></svg></span><span class=\"agy-image-chip-text\">" + translateOr("image.playChip", "Play") + "</span>";
3004
3211
  badge.onclick = (e) => {
3005
3212
  e.preventDefault();
3006
3213
  e.stopPropagation();
@@ -3025,11 +3232,11 @@ window.__ModuleLoader__.load({
3025
3232
  e.stopPropagation();
3026
3233
  const fileName = pathToUse.split(/[/\\]/).pop() || pathToUse;
3027
3234
  if (openInRightSidebar(pathToUse)) {
3028
- showToast(`已在原生边栏打开: ${fileName}`);
3235
+ showToast(translateOr("file.openedInSidebar", "Opened in the sidebar: {name}", { name: fileName }));
3029
3236
  return;
3030
3237
  }
3031
3238
  openInSystem(pathToUse, false).then((res) => {
3032
- showToast(res.ok ? `已在系统程序中打开: ${fileName}` : `打开失败: ${res.error || "未找到文件"}`);
3239
+ showToast(res.ok ? translateOr("file.openedInSystem", "Opened in the system app: {name}", { name: fileName }) : translateOr("file.openFailed", "Could not open: {error}", { error: res.error || translateOr("file.notFound", "file not found") }));
3033
3240
  });
3034
3241
  });
3035
3242
  }
@@ -3084,11 +3291,11 @@ window.__ModuleLoader__.load({
3084
3291
  e.stopPropagation();
3085
3292
  const fileName = pathToUse.split(/[/\\]/).pop() || pathToUse;
3086
3293
  if (openInRightSidebar(pathToUse)) {
3087
- showToast(`已在原生边栏打开: ${fileName}`);
3294
+ showToast(translateOr("file.openedInSidebar", "Opened in the sidebar: {name}", { name: fileName }));
3088
3295
  return;
3089
3296
  }
3090
3297
  openInSystem(pathToUse, false).then((res) => {
3091
- showToast(res.ok ? `已在系统程序中打开: ${fileName}` : `打开失败: ${res.error || "未找到文件"}`);
3298
+ showToast(res.ok ? translateOr("file.openedInSystem", "Opened in the system app: {name}", { name: fileName }) : translateOr("file.openFailed", "Could not open: {error}", { error: res.error || translateOr("file.notFound", "file not found") }));
3092
3299
  });
3093
3300
  }
3094
3301
  }
@@ -3771,7 +3978,7 @@ window.__ModuleLoader__.load({
3771
3978
  const header = document.createElement("div");
3772
3979
  header.className = "agy-decision-header";
3773
3980
  const headerLabel = document.createElement("span");
3774
- headerLabel.textContent = activeTranslate("decision.quickFill");
3981
+ headerLabel.textContent = COPY.quickFill();
3775
3982
  header.appendChild(headerLabel);
3776
3983
  box.appendChild(header);
3777
3984
  const chips = document.createElement("div");
@@ -3780,7 +3987,7 @@ window.__ModuleLoader__.load({
3780
3987
  const chip = document.createElement("button");
3781
3988
  chip.type = "button";
3782
3989
  chip.className = "agy-decision-chip";
3783
- chip.title = activeTranslate("decision.insertTooltip", { text: opt.fullText });
3990
+ chip.title = COPY.insertTooltip(opt.fullText);
3784
3991
  const numSpan = document.createElement("span");
3785
3992
  numSpan.className = "agy-decision-chip-num";
3786
3993
  numSpan.textContent = opt.num ?? "👉";
@@ -3792,7 +3999,7 @@ window.__ModuleLoader__.load({
3792
3999
  chip.onclick = (e) => {
3793
4000
  e.stopPropagation();
3794
4001
  const cleanText = opt.fullText.replace(/^[0-9]+[、..:]\s*/, "").trim();
3795
- insertTextIntoChatComposer(activeTranslate("decision.insertPayload", { choice: (opt.num ? opt.num + " " : "") + cleanText }));
4002
+ insertTextIntoChatComposer(COPY.insertPayload((opt.num ? opt.num + " " : "") + cleanText));
3796
4003
  chip.classList.add("selected");
3797
4004
  setTimeout(() => chip.classList.remove("selected"), 1200);
3798
4005
  };
@@ -3815,24 +4022,14 @@ window.__ModuleLoader__.load({
3815
4022
  scanAndEnhanceDecisions();
3816
4023
  }, 100);
3817
4024
  }
3818
- /** Active translator for the scan pass (module scope: the scan runs outside install). */
3819
- let activeTranslate = (key, params) => {
3820
- return ({
3821
- "decision.quickFill": "💬 Click an option to fill it in:",
3822
- "decision.insertTooltip": "Insert: {text}",
3823
- "decision.insertPayload": "I choose {choice}"
3824
- }[key] ?? key).replace(/\{(\w+)\}/g, (_, name) => String(params?.[name] ?? ""));
4025
+ /** Chip copy: localized through the shared bridge (issue #153). */
4026
+ const COPY = {
4027
+ quickFill: () => translateOr("decision.quickFill", "💬 Click an option to fill it in:"),
4028
+ insertTooltip: (text) => translateOr("decision.insertTooltip", "Insert: {text}", { text }),
4029
+ insertPayload: (choice) => translateOr("decision.insertPayload", "I choose {choice}", { choice })
3825
4030
  };
3826
- function translatorFor(ctx) {
3827
- try {
3828
- const bound = (ctx?.locale)?.bind?.(NS);
3829
- if (typeof bound === "function") return bound;
3830
- } catch {}
3831
- return activeTranslate;
3832
- }
3833
- function installDecisionChips(ctx) {
4031
+ function installDecisionChips() {
3834
4032
  if (typeof window === "undefined" || typeof document === "undefined") return () => {};
3835
- activeTranslate = translatorFor(ctx);
3836
4033
  decisionChipsDispose?.();
3837
4034
  injectStyles$4();
3838
4035
  const observer = new MutationObserver(() => {
@@ -3935,7 +4132,7 @@ window.__ModuleLoader__.load({
3935
4132
  e.stopPropagation();
3936
4133
  onInsert();
3937
4134
  }
3938
- }, inserted ? "✓ 已填入对话框" : "💬 填入对话框 / Insert into Chat"), model.output ? h("div", { className: "agy-tv-q-answered" }, `已记录: ${model.output}`) : null));
4135
+ }, inserted ? translateOr("question.inserted", "✓ Inserted into the chat") : translateOr("question.insert", "💬 Insert into the chat")), model.output ? h("div", { className: "agy-tv-q-answered" }, translateOr("question.recorded", "Recorded: {value}", { value: String(model.output) })) : null));
3939
4136
  }
3940
4137
  //#endregion
3941
4138
  //#region src/client/toolview/card-bodies.ts
@@ -4693,17 +4890,17 @@ body > [id^="iagy-mmd"] .error-icon {
4693
4890
  const toggleBtn = document.createElement("button");
4694
4891
  toggleBtn.type = "button";
4695
4892
  toggleBtn.className = "agy-mermaid-toggle";
4696
- toggleBtn.textContent = "查看源码";
4697
- toggleBtn.title = "切换图表与原始代码";
4893
+ toggleBtn.textContent = translateOr("mermaid.viewSource", "View source");
4894
+ toggleBtn.title = translateOr("mermaid.toggle", "Switch between the diagram and its source");
4698
4895
  toggleBtn.addEventListener("click", (ev) => {
4699
4896
  ev.preventDefault();
4700
4897
  ev.stopPropagation();
4701
4898
  if (block.getAttribute("data-agy-mermaid-view") === "source") {
4702
4899
  block.removeAttribute("data-agy-mermaid-view");
4703
- toggleBtn.textContent = "查看源码";
4900
+ toggleBtn.textContent = translateOr("mermaid.viewSource", "View source");
4704
4901
  } else {
4705
4902
  block.setAttribute("data-agy-mermaid-view", "source");
4706
- toggleBtn.textContent = "查看图表";
4903
+ toggleBtn.textContent = translateOr("mermaid.viewDiagram", "View diagram");
4707
4904
  }
4708
4905
  });
4709
4906
  toolbar.appendChild(toggleBtn);
@@ -4719,7 +4916,7 @@ body > [id^="iagy-mmd"] .error-icon {
4719
4916
  block.setAttribute("data-agy-mermaid", "fallback");
4720
4917
  } else {
4721
4918
  block.setAttribute("data-agy-mermaid", "error");
4722
- mount.innerHTML = "<div class=\"agy-mermaid-warn\">⚠️ Mermaid 图表解析失败,已保留原始代码呈现</div>";
4919
+ mount.innerHTML = "<div class=\"agy-mermaid-warn\">" + translateOr("mermaid.parseFailed", "⚠️ This Mermaid diagram could not be rendered; the source is kept below.") + "</div>";
4723
4920
  }
4724
4921
  } finally {
4725
4922
  cleanupTempElements(id);
@@ -6156,12 +6353,16 @@ body.dark .agy-tsl-card,
6156
6353
  if (host) host.appendChild(st);
6157
6354
  }
6158
6355
  }
6159
- /** Check if document language is Chinese or English. */
6356
+ /**
6357
+ * Card title, from the plugin's locale binding.
6358
+ *
6359
+ * `document.documentElement.lang` used to be consulted here as a shortcut, but it
6360
+ * is DSH's page language rather than this plugin's locale, and it made the copy
6361
+ * disagree with every other surface when the two differed. The binding is the
6362
+ * authority; hosts without one get the English default (issue #153).
6363
+ */
6160
6364
  function getCompactionTitle() {
6161
- if (typeof document !== "undefined") {
6162
- if ((document.documentElement.lang || "").startsWith("en")) return "Context compacted";
6163
- }
6164
- return "上下文已压缩";
6365
+ return translateOr("compaction.contextCompacted", "Context compacted");
6165
6366
  }
6166
6367
  function buildCompactionRow(notice) {
6167
6368
  const { beforeTokens, afterTokens, summary = "" } = notice;
@@ -10372,6 +10573,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
10372
10573
  };
10373
10574
  }, "agy-link: status polling");
10374
10575
  const locale = ctx.locale;
10576
+ bindTranslator(ctx);
10375
10577
  ctx.effect(() => {
10376
10578
  const safeAddLanguage = (lang) => {
10377
10579
  try {
@@ -10474,7 +10676,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
10474
10676
  ctx.effect(() => installAutoExpandReasoning());
10475
10677
  ctx.effect(() => installMermaidRendering());
10476
10678
  ctx.effect(() => installImageEnhancer(ctx));
10477
- ctx.effect(() => installDecisionChips(ctx));
10679
+ ctx.effect(() => installDecisionChips());
10478
10680
  ctx.effect(() => installCompactionCard());
10479
10681
  ctx.effect(() => {
10480
10682
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agy-link",
3
- "version": "0.6.53",
3
+ "version": "0.6.54",
4
4
  "description": "Google Antigravity (agy CLI) models for DeepSeek Harness — stream Gemini/Claude/GPT-OSS subscriptions into DSH with thinking, tool activity, token usage and in-GUI Google OAuth login.",
5
5
  "type": "module",
6
6
  "license": "MIT",