fix(i18n): zh-CN for the case picker rows, Bottom bar settings, new toasts, tile and spreadsheet text

- Case picker: the "New or link a case…" and "Case settings…" rows that
  replaced the translated + and gear buttons get zh-CN entries reusing the
  buttons' wording, plus the list's "No cases match".
- App Settings, Bottom bar: the whole group translates as one (heading, the
  four Git status rows with #543's max repositories and git timeout, and
  their descriptions), so it never reads half English. The Git panel's two
  button names, which the new "Git status" key reaches, read naturally too.
- Toasts: the three "Could not open a new window for this ..." errors and
  the dictation-closed warning.
- Spreadsheet preview: "Spreadsheet preview failed (<status>)" gets a
  pattern. Worker refusals map their error code to one user sentence each in
  the renderer (the raw message goes to the console), feature ids read as
  words (pivot tables, external links), and the notice bar translates each
  item before the join; a number format's code passes through untouched.
  The worker and core are unchanged, so their pinned strings and the
  asset version hash stay as they were.
- Header Stats Style Tiles: the connection tile's value word reads in
  Chinese through scoped "Connection tile: <word>" keys, never bare-word
  keys ("retry" is also the orchestrator's Retry button, "LIVE" a resume
  list badge). The indicator cache now includes the UI language, so a
  language switch repaints it on the next update.
- Tile grid: the "Loading…" label was CSS content text the translator
  cannot reach; it is now content: attr(data-loading-label), written through
  the translator when the tile is built and each time it starts loading.

Tests pin every new string (zh differs, no English left, English unchanged)
and fail without these changes: the tile harvest sees the loading label and
the rename field, a CSS guard keeps words out of tile generated content, the
Bottom bar group, the case picker rows and toasts read from their source,
the connection tile across a language switch, and the spreadsheet error
codes, notice bar and status line.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer
2026-10-09 09:23:05 +02:00
parent 41643f2b38
commit 82c87f56d1
11 changed files with 533 additions and 11 deletions
+22 -1
View File
@@ -985,6 +985,7 @@ class CodemanApp {
// Last rendered connection-indicator tuple; the hot input path skips DOM
// writes when the freshly computed descriptor is identical (COD-136).
this._lastIndicatorDescriptor = null;
this._lastIndicatorLanguage = null; // the UI language it was rendered in
this._postDraining = new Set(); // sessionIds with an in-flight POST drainer
// Terminal sockets OTHER than the primary one (`this._ws`), keyed by the
// session they are bound to: the split pane's second terminal registers its
@@ -4354,6 +4355,21 @@ class CodemanApp {
}
}
/**
* The tile's value word as shown: i18n.js's scoped 'Connection tile: <word>'
* entry in Chinese, the English word otherwise. Never a bare-word key: those
* would also translate other text ("retry" is the orchestrator's Retry button),
* which is why the value span carries data-i18n-skip.
* @param {string} value
* @returns {string}
*/
_connectionTileValueText(value) {
if (!value) return '';
const key = `Connection tile: ${value}`;
const translated = typeof window.codemanT === 'function' ? window.codemanT(key) : key;
return translated && translated !== key ? translated : value;
}
_updateConnectionIndicator() {
const indicator = this.$('connectionIndicator');
const dot = this.$('connectionDot');
@@ -4365,8 +4381,12 @@ class CodemanApp {
// writes when nothing changed (COD-136) — the compute above is DOM-free.
const next = this._computeConnectionDescriptor();
const prev = this._lastIndicatorDescriptor;
// The tile's value word is written in the UI language, so a language
// switch counts as a change too.
const language = window.CodemanI18n?.language || 'en';
if (
prev &&
language === this._lastIndicatorLanguage &&
prev.display === next.display &&
prev.dotClass === next.dotClass &&
prev.text === next.text &&
@@ -4375,6 +4395,7 @@ class CodemanApp {
return;
}
this._lastIndicatorDescriptor = next;
this._lastIndicatorLanguage = language;
indicator.style.display = next.display;
if (next.display !== 'none') {
@@ -4386,7 +4407,7 @@ class CodemanApp {
if (tileLabel && tileValue) {
const words = this._connectionTileWords(next);
tileLabel.textContent = words.label;
tileValue.textContent = words.value;
tileValue.textContent = this._connectionTileValueText(words.value);
tileValue.className = `connection-tile-value ${words.state}`.trim();
}
}
+60
View File
@@ -230,6 +230,11 @@
'Create New Case': '新建案例',
'Create new case': '新建案例',
'Link Existing': '关联现有目录',
// The toolbar case picker's action rows (session-ui.js CASE_PICKER_ACTIONS),
// which replaced the "+" and gear buttons, and its empty state.
'New or link a case…': '新建或关联案例…',
'Case settings…': '案例设置…',
'No cases match': '没有匹配的案例',
'Add Case': '添加案例',
'Open sessions': '打开会话',
'Recent Sessions': '最近会话',
@@ -379,6 +384,32 @@
'As before (bars)': '与以前相同(进度条)',
'Compact (default)': '紧凑(默认)',
'Tiles (label over value)': '磁贴(标签在数值上方)',
// The connection tile's value word in that style (app.js
// _connectionTileValueText). Scoped keys on purpose: the bare words also
// name other things ("retry" is the orchestrator's Retry button, "LIVE" a
// badge in the resume list), and a bare key would translate those too.
'Connection tile: live': '已连接',
'Connection tile: fallback': '回退',
'Connection tile: offline': '离线',
'Connection tile: queued': '已排队',
'Connection tile: retry': '重连中',
// App Settings → Bottom bar, translated as one group (the Git status rows,
// #543's two included). Keys are the trimmed label text, without the scope tag.
'Bottom bar': '底部栏',
'Git status': 'Git 状态',
"Shows, at the right of the bottom bar, when the active session's repository (or each repository inside its folder, up to two levels down) has uncommitted files or commits that are not pushed. Click it for the list. Read-only: Codeman never fetches or changes the repository. Not shown for Docker or remote sessions. Off by default.":
'在底部栏右侧显示当前会话的仓库(或其文件夹内向下两层以内的每个仓库)是否有未提交的文件或未推送的提交。点击可查看列表。只读:{name} 从不拉取或更改仓库。Docker 和远程会话不显示。默认关闭。',
'Git status: group files by folder': 'Git 状态:按文件夹分组显示文件',
'In the Git window, show changed files under their folders, collapsed until you click a folder. Off lists every file by its full path. On by default.':
'在 Git 窗口中,将更改的文件显示在各自的文件夹下,点击文件夹前保持折叠。关闭时按完整路径列出每个文件。默认开启。',
'Git status: max repositories': 'Git 状态:最多仓库数',
"When the session's folder holds several projects instead of being one, the Git window lists up to this many (1 to 50, default 12). Each one costs a few git commands per refresh.":
'当会话的文件夹包含多个项目(而不是本身就是一个项目)时,Git 窗口最多列出这么多个(1 到 50,默认 12)。每个仓库每次刷新都要运行几条 git 命令。',
'Git status: git timeout': 'Git 状态:git 超时',
'Seconds one git command may run before that repository is reported as unreadable (5 to 120, default 30). Raise it for repositories on a slow network share.':
'单条 git 命令可运行的秒数,超时后该仓库会被报告为无法读取(5 到 120,默认 30)。仓库位于较慢的网络共享上时请调高此值。',
'Refresh git status': '刷新 Git 状态',
'Close git status': '关闭 Git 状态',
Panels: '面板',
Monitor: '监视器',
'Project Insights': '项目洞察',
@@ -699,6 +730,13 @@
'Nothing to copy': '没有可复制的内容',
// A `#session=<id>` link whose session never appeared (app.js _armUrlSessionWait).
'Session not found': '未找到会话',
// A native host that would not open a window (app.js openInHostWindow); the
// "dashboard" is a web tab.
'Could not open a new window for this session': '无法在新窗口中打开此会话',
'Could not open a new window for this preview': '无法在新窗口中打开此预览',
'Could not open a new window for this dashboard': '无法在新窗口中打开此网页标签',
// Dictation whose session closed before the text was sent (voice-input.js).
'That session has closed; dictation not sent': '该会话已关闭,语音输入未发送',
// Terminal touch-selection bar (long-press to select). The bar is a sibling of
// `.xterm`, not a descendant, so SKIP_SELECTOR does not cover it and these apply.
Copy: '复制',
@@ -872,6 +910,24 @@
'Spreadsheet parser message failed.': '电子表格解析器消息出错。',
'Spreadsheet parser message failed': '电子表格解析器消息出错',
'Spreadsheet preview is unavailable.': '电子表格预览不可用。',
'Spreadsheet preview must use a same-origin URL': '电子表格预览必须使用同源 URL',
// Worker refusals, one sentence per error code (spreadsheet-preview.js
// WORKER_ERROR_TEXT), and the notice bar's items (renderWarnings). The
// counted ones are patterns in translateDynamic below.
'This workbook is password-protected or in the old .xls format, so it cannot be previewed.':
'此工作簿受密码保护或为旧版 .xls 格式,无法预览。',
'This workbook uses ZIP64, which the preview does not support.': '此工作簿使用 ZIP64 格式,预览不支持该格式。',
'This workbook is too large or complex to preview.': '此工作簿过大或过于复杂,无法预览。',
'This workbook could not be read. The file may be damaged or not a valid .xlsx file.':
'无法读取此工作簿。文件可能已损坏,或不是有效的 .xlsx 文件。',
charts: '图表',
drawings: '绘图',
'pivot tables': '数据透视表',
'external links': '外部链接',
macros: '宏',
'Formula has no cached result': '公式没有缓存的计算结果',
'Unsupported cell value': '不支持的单元格值',
'Unsupported number format': '不支持的数字格式',
'Export as JSON': '导出为 JSON',
'Export as Markdown': '导出为 Markdown',
'Mark all read': '全部标为已读',
@@ -1099,6 +1155,10 @@
[/^Selected: (.+)$/, (_m, value) => `已选择:${value}`],
[/^Failed to (.+)$/, (_m, action) => `操作失败:${action}`],
[/^Will create: (.+)$/, (_m, path) => `将创建:${path}`],
// The spreadsheet preview: an HTTP status, and the notice bar's counts.
[/^Spreadsheet preview failed \((\d+)\)$/, (_m, status) => `电子表格预览失败(${status})`],
[/^View truncated to the first (\d+) cells$/, (_m, n) => `视图仅显示前 ${n} 个单元格`],
[/^(\d+) unsupported number formats$/, (_m, n) => `${n} 种不支持的数字格式`],
// Group names are user text: they pass through untranslated.
[/^Move to "(.+)"$/, (_m, group) => `移到“${group}”`],
[
+1 -1
View File
@@ -154,7 +154,7 @@
<div class="connection-indicator" id="connectionIndicator" style="display: none;">
<span class="connection-dot" id="connectionDot"></span>
<span class="connection-text" id="connectionText"></span>
<span class="connection-tile"><span class="connection-tile-label" id="connectionTileLabel"></span><span class="connection-tile-value" id="connectionTileValue"></span></span>
<span class="connection-tile"><span class="connection-tile-label" id="connectionTileLabel"></span><span class="connection-tile-value" id="connectionTileValue" data-i18n-skip></span></span>
</div>
<div class="header-font-controls">
<button class="btn-icon-header btn-sm" onclick="app.decreaseFontSize()" title="Decrease font (Ctrl+-)" aria-label="Decrease font size">A-</button>
+64 -4
View File
@@ -31,6 +31,67 @@
workerUrl: `/spreadsheet-preview-worker.js?v=${SPREADSHEET_ASSET_VERSION}`,
});
// What a refusal from the worker says on screen. The core's own messages
// (spreadsheet-xlsx-core.js) are developer detail, so each error code maps to
// one sentence with a zh-CN entry in i18n.js, and the raw message goes to the
// console. Any other code (parse-failed carries ExcelJS's own exception text)
// shows the generic failure.
const TOO_LARGE_OR_COMPLEX = 'This workbook is too large or complex to preview.';
const UNREADABLE = 'This workbook could not be read. The file may be damaged or not a valid .xlsx file.';
const WORKER_ERROR_TEXT = Object.freeze({
encrypted: 'This workbook is password-protected or in the old .xls format, so it cannot be previewed.',
zip64: 'This workbook uses ZIP64, which the preview does not support.',
malformed: UNREADABLE,
'number-format': UNREADABLE,
'entry-limit': TOO_LARGE_OR_COMPLEX,
'entry-size': TOO_LARGE_OR_COMPLEX,
'inflated-size': TOO_LARGE_OR_COMPLEX,
'compression-ratio': TOO_LARGE_OR_COMPLEX,
'worksheet-limit': TOO_LARGE_OR_COMPLEX,
'element-limit': TOO_LARGE_OR_COMPLEX,
'row-limit': TOO_LARGE_OR_COMPLEX,
'cell-limit': TOO_LARGE_OR_COMPLEX,
'merge-limit': TOO_LARGE_OR_COMPLEX,
'style-limit': TOO_LARGE_OR_COMPLEX,
});
// The workbook features the preview leaves out, as the core names them
// (featureForName), in words for the notice bar.
const FEATURE_LABELS = Object.freeze({
charts: 'charts',
drawings: 'drawings',
pivotTables: 'pivot tables',
externalLinks: 'external links',
macros: 'macros',
});
const UNSUPPORTED_FORMAT_PREFIX = 'Unsupported number format: ';
function translate(text) {
return global.codemanT?.(text) || text;
}
function own(map, key) {
return Object.prototype.hasOwnProperty.call(map, key);
}
function workerErrorText(payload) {
const code = String(payload?.code || '');
if (payload?.message) console.warn(`Spreadsheet preview: ${code || 'error'}: ${payload.message}`);
return own(WORKER_ERROR_TEXT, code) ? WORKER_ERROR_TEXT[code] : 'Spreadsheet preview failed';
}
// One notice bar item, translated on its own (the bar is one text node, which
// the i18n layer could only match whole). A number format's code is workbook
// text: it is appended as is, never passed through the translator, which
// would read a `{…}` in it as a placeholder.
function warningText(warning) {
const text = String(warning);
if (text.startsWith(UNSUPPORTED_FORMAT_PREFIX)) {
return `${translate('Unsupported number format')}: ${text.slice(UNSUPPORTED_FORMAT_PREFIX.length)}`;
}
return translate(own(FEATURE_LABELS, text) ? FEATURE_LABELS[text] : text);
}
function message(container, text, kind) {
container.textContent = '';
const state = document.createElement('div');
@@ -209,9 +270,8 @@
if (!notice) return;
const warnings = [...(metadata?.warnings || []), ...(tileWarnings || [])];
notice.hidden = warnings.length === 0;
const warningLabel =
global.codemanT?.('Some workbook features are not shown') || 'Some workbook features are not shown';
notice.textContent = warnings.length ? `${warningLabel}: ${warnings.join(', ')}` : '';
const warningLabel = translate('Some workbook features are not shown');
notice.textContent = warnings.length ? `${warningLabel}: ${warnings.map(warningText).join(', ')}` : '';
}
function pinHeadings() {
@@ -459,7 +519,7 @@
clearTimer();
renderMetadata(payload);
} else if (payload.type === 'tile') renderTile(payload);
else if (payload.type === 'error') fail(payload.message);
else if (payload.type === 'error') fail(workerErrorText(payload));
};
worker.onerror = () => fail('Spreadsheet parser failed.');
worker.onmessageerror = () => fail('Spreadsheet parser message failed.');
+4 -2
View File
@@ -19843,9 +19843,11 @@ body.tile-grid-resizing--row * {
}
/* Quiet "loading" state while the tile's capture waits in the grid's one load
queue (or runs). */
queue (or runs). The text is the body's data-loading-label, which tile-grid.js
writes in the UI language (_setTileLoadingLabel): generated content is out of
the i18n layer's reach, so no literal words here. */
.tile.tile--loading .tile-body::after {
content: 'Loading\2026';
content: attr(data-loading-label);
position: absolute;
top: 6px;
right: 10px;
+14
View File
@@ -233,6 +233,8 @@ Object.assign(CodemanApp.prototype, {
onChange: (tile, state) => {
const entry = grid.tiles.get(tile.sessionId);
if (entry?.tile !== tile) return;
// Rewritten on the way in, so a language switched since is picked up.
if (state !== 'idle') this._setTileLoadingLabel(entry.body);
entry.el.classList.toggle('tile--loading', state !== 'idle');
// The first capture has landed (or failed): the terminal fades in,
// whole, instead of showing its replay scroll by.
@@ -243,6 +245,17 @@ Object.assign(CodemanApp.prototype, {
return grid.queue;
},
/**
* The "Loading…" label of a tile body. It is CSS generated content (styles.css,
* `content: attr(data-loading-label)`), which the i18n layer never reaches, so
* the text is written here in the UI language.
*/
_setTileLoadingLabel(body) {
if (!body) return;
const t = window.codemanT;
body.dataset.loadingLabel = typeof t === 'function' ? t('Loading…') : 'Loading…';
},
_tileGridSection() {
let section = document.getElementById('tileGrid');
if (!section) {
@@ -1336,6 +1349,7 @@ Object.assign(CodemanApp.prototype, {
const header = this._buildTileHeader(sessionId);
const body = document.createElement('div');
body.className = 'tile-body';
this._setTileLoadingLabel(body);
el.append(header.el, body);
// Pressing a tile is a human selection: it focuses the tile and
// acknowledges its idle alert (the already-focused tile hits