From 0904df4fc87e57defae13e77dfa7402a59cef6e2 Mon Sep 17 00:00:00 2001 From: Danyang Chen Date: Thu, 19 Nov 2026 17:59:34 +0800 Subject: [PATCH] Read the Bot tree's sidebar in the window's language (#3114) The Archived Bots group, the row status tags and the reorganization notice drew bare English in a zh window. They now go through tr() with twelve new zh entries, and the three i18n baselines lose the eleven pins that held those draws. Part of #3114 Docs-not-needed: the tree page describes the panel's structure and slots, not the language its copy is drawn in. --- changelog.d/3114-tree-sidebar-zh.changed.md | 1 + core/client.js | 14 +++ core/src/client/i18n.js | 14 +++ core/test/i18n-missing-entries.baseline.json | 7 -- core/test/i18n-missing-entries.test.js | 4 +- core/test/i18n-plugins.baseline.json | 1 - core/test/i18n-template-draws.baseline.json | 5 +- patches/ds-bot/0001-core-fixes.patch | 16 ++- patches/ds-bot/0008-client-bundle.patch | 16 ++- .../test/i18n-missing-entries.baseline.json | 7 -- .../files/test/i18n-missing-entries.test.js | 4 +- .../files/test/i18n-plugins.baseline.json | 1 - .../test/i18n-template-draws.baseline.json | 5 +- plugins/tree/client.js | 35 +++--- plugins/tree/test/sidebar-i18n.test.js | 106 ++++++++++++++++++ 15 files changed, 193 insertions(+), 43 deletions(-) create mode 100644 changelog.d/3114-tree-sidebar-zh.changed.md create mode 100644 plugins/tree/test/sidebar-i18n.test.js diff --git a/changelog.d/3114-tree-sidebar-zh.changed.md b/changelog.d/3114-tree-sidebar-zh.changed.md new file mode 100644 index 000000000..b3c08bbc7 --- /dev/null +++ b/changelog.d/3114-tree-sidebar-zh.changed.md @@ -0,0 +1 @@ +The Bot tree's sidebar copy — the Archived Bots group, its status tags, and the reorganization notice's title, Undo/Dismiss buttons, "and N more" line and kept names — now follows the window's language, so a Chinese window no longer reads English there; a window without a translator still reads today's English ([#3114](https://github.com/ThinkFlowLab/FlyBot/issues/3114)). diff --git a/core/client.js b/core/client.js index c395cd066..33bc98002 100644 --- a/core/client.js +++ b/core/client.js @@ -252,6 +252,20 @@ var ZH = { // Sidebar and account menu "Bot list": "Bot 列表", "Bot tree": "Bot 树", + // #3114 cut 19: the Bot tree's sidebar — the Archived Bots group, its status tags, and the + // reorganization notice's title, Undo/Dismiss, "and N more" line and kept names. + "Archived bots": "已归档的 Bot", + "Archived ({count})": "已归档({count})", + "Tree reorganized": "Bot 树已重组", + "Tree reorganization undone": "已撤销 Bot 树重组", + "and {count} more": "还有 {count} 条", + "Kept: {names}": "保留:{names}", + "archived · merged into {name}": "已归档 · 并入 {name}", + archived: "已归档", + retired: "已退役", + idle: "空闲", + "outside the tree": "不在树中", + Undo: "撤销", "no longer shared": "已不再共享", "Messages waiting for your approval": "等你批准的消息", "Waiting for approval": "等待批准", diff --git a/core/src/client/i18n.js b/core/src/client/i18n.js index d1e07a07f..cc52f45e4 100644 --- a/core/src/client/i18n.js +++ b/core/src/client/i18n.js @@ -219,6 +219,20 @@ const ZH = { // Sidebar and account menu 'Bot list': 'Bot 列表', 'Bot tree': 'Bot 树', + // #3114 cut 19: the Bot tree's sidebar — the Archived Bots group, its status tags, and the + // reorganization notice's title, Undo/Dismiss, "and N more" line and kept names. + 'Archived bots': '已归档的 Bot', + 'Archived ({count})': '已归档({count})', + 'Tree reorganized': 'Bot 树已重组', + 'Tree reorganization undone': '已撤销 Bot 树重组', + 'and {count} more': '还有 {count} 条', + 'Kept: {names}': '保留:{names}', + 'archived · merged into {name}': '已归档 · 并入 {name}', + archived: '已归档', + retired: '已退役', + idle: '空闲', + 'outside the tree': '不在树中', + Undo: '撤销', 'no longer shared': '已不再共享', 'Messages waiting for your approval': '等你批准的消息', 'Waiting for approval': '等待批准', diff --git a/core/test/i18n-missing-entries.baseline.json b/core/test/i18n-missing-entries.baseline.json index ffbd2fa3d..f1787dbe1 100644 --- a/core/test/i18n-missing-entries.baseline.json +++ b/core/test/i18n-missing-entries.baseline.json @@ -145,15 +145,8 @@ "plugins/timeline/client.js:{} waiting", "plugins/timeline/client.js:{}h {}m", "plugins/timeline/client.js:{}m {}s", - "plugins/tree/client.js:Archived bots", "plugins/tree/client.js:No child bots yet. Ask Chief to take on a task and it will create child bots.", "plugins/tree/client.js:Tree", - "plugins/tree/client.js:Tree reorganization undone", - "plugins/tree/client.js:Tree reorganized#1", - "plugins/tree/client.js:Tree reorganized#2", - "plugins/tree/client.js:Undo", - "plugins/tree/client.js:archived · merged into {}", - "plugins/tree/client.js:outside the tree", "plugins/workflow/client.js:Names the connectors this run Bot may use: github grants mcp__github__*, composio grants the Composio connector. File and shell access is always full, like a normal Bot, and a node that names no connector gets none.", "plugins/workflow/client.js:这里填这个节点 Bot 能用的连接器:github 对应 mcp__github__*,composio 对应 Composio 连接器。文件与 shell 权限始终与普通 Bot 相同(完全放开);不填连接器时这个节点一个都拿不到。" ] diff --git a/core/test/i18n-missing-entries.test.js b/core/test/i18n-missing-entries.test.js index ac1d5d3dd..015761596 100644 --- a/core/test/i18n-missing-entries.test.js +++ b/core/test/i18n-missing-entries.test.js @@ -208,8 +208,8 @@ test('the widening only adds pins and never admits a glyph', () => { 'plugins/timeline/client.js:Timeline#1', 'plugins/timeline/client.js:Timeline#2', 'plugins/timeline/client.js:Timeline#3', - 'plugins/tree/client.js:Tree reorganized#1', - 'plugins/tree/client.js:Tree reorganized#2', + 'plugins/tree/client.js:Tree', + 'plugins/tree/client.js:No child bots yet. Ask Chief to take on a task and it will create child bots.', ]) assert.ok(current.has(entry), `${entry} is pinned`) for (const pin of current) assert.match(pin, /\p{L}/u, `${pin} names a sentence, not a glyph`) }) diff --git a/core/test/i18n-plugins.baseline.json b/core/test/i18n-plugins.baseline.json index 9e9ad3624..7640c6bf8 100644 --- a/core/test/i18n-plugins.baseline.json +++ b/core/test/i18n-plugins.baseline.json @@ -16,7 +16,6 @@ "plugins/timeline/client.js:Window", "plugins/tree/client.js:Bot tree", "plugins/tree/client.js:Copy invite link", - "plugins/tree/client.js:Dismiss", "plugins/workflow/client.js:Instructions" ] } diff --git a/core/test/i18n-template-draws.baseline.json b/core/test/i18n-template-draws.baseline.json index a686acef1..764dbee01 100644 --- a/core/test/i18n-template-draws.baseline.json +++ b/core/test/i18n-template-draws.baseline.json @@ -33,10 +33,7 @@ "plugins/timeline/client.js:busy {} (model {} · tools {}) · no running turn {} · {} turn{}{}{}", "plugins/timeline/client.js:{} request{} not answered yet.", "plugins/timeline/client.js:{}: model {}%, tools {}%, no running turn {}%", - "plugins/tree/client.js:Archived ({})", "plugins/tree/client.js:Collapse {}", - "plugins/tree/client.js:Copy invite link for {}", - "plugins/tree/client.js:Kept: {}", - "plugins/tree/client.js:and {} more" + "plugins/tree/client.js:Copy invite link for {}" ] } diff --git a/patches/ds-bot/0001-core-fixes.patch b/patches/ds-bot/0001-core-fixes.patch index 4f3f46aa7..54f7efc7a 100644 --- a/patches/ds-bot/0001-core-fixes.patch +++ b/patches/ds-bot/0001-core-fixes.patch @@ -895,7 +895,7 @@ diff --git a/src/client/i18n.js b/src/client/i18n.js Content: '内容', 'Referenced {labels}': '引用了 {labels}', ', ': '、', -@@ -41,22 +41,93 @@ const ZH = { +@@ -41,22 +41,107 @@ const ZH = { ' and ': '、', and: '和', '{count} members': '{count} 位成员', @@ -942,6 +942,20 @@ diff --git a/src/client/i18n.js b/src/client/i18n.js // Sidebar and account menu 'Bot list': 'Bot 列表', + 'Bot tree': 'Bot 树', ++ // #3114 cut 19: the Bot tree's sidebar — the Archived Bots group, its status tags, and the ++ // reorganization notice's title, Undo/Dismiss, "and N more" line and kept names. ++ 'Archived bots': '已归档的 Bot', ++ 'Archived ({count})': '已归档({count})', ++ 'Tree reorganized': 'Bot 树已重组', ++ 'Tree reorganization undone': '已撤销 Bot 树重组', ++ 'and {count} more': '还有 {count} 条', ++ 'Kept: {names}': '保留:{names}', ++ 'archived · merged into {name}': '已归档 · 并入 {name}', ++ archived: '已归档', ++ retired: '已退役', ++ idle: '空闲', ++ 'outside the tree': '不在树中', ++ Undo: '撤销', + 'no longer shared': '已不再共享', + 'Messages waiting for your approval': '等你批准的消息', + 'Waiting for approval': '等待批准', diff --git a/patches/ds-bot/0008-client-bundle.patch b/patches/ds-bot/0008-client-bundle.patch index 6aeb839a3..293c2fdb6 100644 --- a/patches/ds-bot/0008-client-bundle.patch +++ b/patches/ds-bot/0008-client-bundle.patch @@ -160,7 +160,7 @@ diff --git a/client.js b/client.js Content: "内容", "Referenced {labels}": "引用了 {labels}", ", ": "、", -@@ -78,21 +78,92 @@ var ZH = { +@@ -78,21 +78,106 @@ var ZH = { " and ": "、", and: "和", "{count} members": "{count} 位成员", @@ -206,6 +206,20 @@ diff --git a/client.js b/client.js // Sidebar and account menu "Bot list": "Bot 列表", + "Bot tree": "Bot 树", ++ // #3114 cut 19: the Bot tree's sidebar — the Archived Bots group, its status tags, and the ++ // reorganization notice's title, Undo/Dismiss, "and N more" line and kept names. ++ "Archived bots": "已归档的 Bot", ++ "Archived ({count})": "已归档({count})", ++ "Tree reorganized": "Bot 树已重组", ++ "Tree reorganization undone": "已撤销 Bot 树重组", ++ "and {count} more": "还有 {count} 条", ++ "Kept: {names}": "保留:{names}", ++ "archived · merged into {name}": "已归档 · 并入 {name}", ++ archived: "已归档", ++ retired: "已退役", ++ idle: "空闲", ++ "outside the tree": "不在树中", ++ Undo: "撤销", + "no longer shared": "已不再共享", + "Messages waiting for your approval": "等你批准的消息", + "Waiting for approval": "等待批准", diff --git a/patches/ds-bot/files/test/i18n-missing-entries.baseline.json b/patches/ds-bot/files/test/i18n-missing-entries.baseline.json index ffbd2fa3d..f1787dbe1 100644 --- a/patches/ds-bot/files/test/i18n-missing-entries.baseline.json +++ b/patches/ds-bot/files/test/i18n-missing-entries.baseline.json @@ -145,15 +145,8 @@ "plugins/timeline/client.js:{} waiting", "plugins/timeline/client.js:{}h {}m", "plugins/timeline/client.js:{}m {}s", - "plugins/tree/client.js:Archived bots", "plugins/tree/client.js:No child bots yet. Ask Chief to take on a task and it will create child bots.", "plugins/tree/client.js:Tree", - "plugins/tree/client.js:Tree reorganization undone", - "plugins/tree/client.js:Tree reorganized#1", - "plugins/tree/client.js:Tree reorganized#2", - "plugins/tree/client.js:Undo", - "plugins/tree/client.js:archived · merged into {}", - "plugins/tree/client.js:outside the tree", "plugins/workflow/client.js:Names the connectors this run Bot may use: github grants mcp__github__*, composio grants the Composio connector. File and shell access is always full, like a normal Bot, and a node that names no connector gets none.", "plugins/workflow/client.js:这里填这个节点 Bot 能用的连接器:github 对应 mcp__github__*,composio 对应 Composio 连接器。文件与 shell 权限始终与普通 Bot 相同(完全放开);不填连接器时这个节点一个都拿不到。" ] diff --git a/patches/ds-bot/files/test/i18n-missing-entries.test.js b/patches/ds-bot/files/test/i18n-missing-entries.test.js index ac1d5d3dd..015761596 100644 --- a/patches/ds-bot/files/test/i18n-missing-entries.test.js +++ b/patches/ds-bot/files/test/i18n-missing-entries.test.js @@ -208,8 +208,8 @@ test('the widening only adds pins and never admits a glyph', () => { 'plugins/timeline/client.js:Timeline#1', 'plugins/timeline/client.js:Timeline#2', 'plugins/timeline/client.js:Timeline#3', - 'plugins/tree/client.js:Tree reorganized#1', - 'plugins/tree/client.js:Tree reorganized#2', + 'plugins/tree/client.js:Tree', + 'plugins/tree/client.js:No child bots yet. Ask Chief to take on a task and it will create child bots.', ]) assert.ok(current.has(entry), `${entry} is pinned`) for (const pin of current) assert.match(pin, /\p{L}/u, `${pin} names a sentence, not a glyph`) }) diff --git a/patches/ds-bot/files/test/i18n-plugins.baseline.json b/patches/ds-bot/files/test/i18n-plugins.baseline.json index 9e9ad3624..7640c6bf8 100644 --- a/patches/ds-bot/files/test/i18n-plugins.baseline.json +++ b/patches/ds-bot/files/test/i18n-plugins.baseline.json @@ -16,7 +16,6 @@ "plugins/timeline/client.js:Window", "plugins/tree/client.js:Bot tree", "plugins/tree/client.js:Copy invite link", - "plugins/tree/client.js:Dismiss", "plugins/workflow/client.js:Instructions" ] } diff --git a/patches/ds-bot/files/test/i18n-template-draws.baseline.json b/patches/ds-bot/files/test/i18n-template-draws.baseline.json index a686acef1..764dbee01 100644 --- a/patches/ds-bot/files/test/i18n-template-draws.baseline.json +++ b/patches/ds-bot/files/test/i18n-template-draws.baseline.json @@ -33,10 +33,7 @@ "plugins/timeline/client.js:busy {} (model {} · tools {}) · no running turn {} · {} turn{}{}{}", "plugins/timeline/client.js:{} request{} not answered yet.", "plugins/timeline/client.js:{}: model {}%, tools {}%, no running turn {}%", - "plugins/tree/client.js:Archived ({})", "plugins/tree/client.js:Collapse {}", - "plugins/tree/client.js:Copy invite link for {}", - "plugins/tree/client.js:Kept: {}", - "plugins/tree/client.js:and {} more" + "plugins/tree/client.js:Copy invite link for {}" ] } diff --git a/plugins/tree/client.js b/plugins/tree/client.js index 0c4694e03..bf2cdbcbe 100644 --- a/plugins/tree/client.js +++ b/plugins/tree/client.js @@ -10,6 +10,15 @@ window.__ModuleLoader__.load({ id: '@flybot/tree', factory: (require) => { const { createElement: h, useEffect, useState, useCallback } = require('react') + // The window's translator when the host has one; without it this panel keeps today's English + // word for word, and a placeholder the caller did not pass stays a placeholder (#3114). + const tr = (text, params) => { + const fn = globalThis.__flybot__?.t + if (typeof fn === 'function') { + try { return fn(text, params) } catch { /* fall through to the English */ } + } + return String(text).replace(/\{(\w+)\}/g, (_, key) => (params && key in params ? String(params[key]) : `{${key}}`)) + } // Browser API (the injected flybot service, ds-bot's FlyBotClient): bots() -> [{ id, name, fields: { [plugin]: {...} } }] // (sync or a Promise) and fields.on('change', fn). It has no on('bot.removed'); removals are picked up @@ -225,7 +234,7 @@ window.__ModuleLoader__.load({ return [ { id: 'copy-invite', - label: 'Copy invite link', + label: tr('Copy invite link'), visible: can && readOnly !== true, run: async () => { const result = await copyInvite(flybot, id, 'link') @@ -433,14 +442,14 @@ window.__ModuleLoader__.load({ function ReorgCard({ run, busy = false, note = null, locked = false, onUndo, onDismiss }) { const lines = run.summary ?? [] const undone = Boolean(run.undone) - return h('div', { className: 'flybot-reorg', role: 'status', 'aria-label': 'Tree reorganized' }, - h('div', { className: 'flybot-reorg-title' }, undone ? 'Tree reorganization undone' : 'Tree reorganized', h('span', { className: 'flybot-reorg-time' }, clock(run.at))), + return h('div', { className: 'flybot-reorg', role: 'status', 'aria-label': tr('Tree reorganized') }, + h('div', { className: 'flybot-reorg-title' }, undone ? tr('Tree reorganization undone') : tr('Tree reorganized'), h('span', { className: 'flybot-reorg-time' }, clock(run.at))), h('ul', { className: 'flybot-reorg-list' }, ...lines.slice(0, NOTICE_LINES).map((line, i) => h('li', { key: i }, line)), - lines.length > NOTICE_LINES ? h('li', { key: 'more' }, `and ${lines.length - NOTICE_LINES} more`) : null), - undone && run.undone.kept?.length ? h('div', { className: 'flybot-reorg-note' }, `Kept: ${run.undone.kept.join('; ')}`) : null, + lines.length > NOTICE_LINES ? h('li', { key: 'more' }, tr('and {count} more', { count: lines.length - NOTICE_LINES })) : null), + undone && run.undone.kept?.length ? h('div', { className: 'flybot-reorg-note' }, tr('Kept: {names}', { names: run.undone.kept.join('; ') })) : null, locked ? null : h('div', { className: 'flybot-reorg-actions' }, - undone ? null : h('button', { type: 'button', className: 'flybot-reorg-btn', disabled: busy, onClick: onUndo }, 'Undo'), - h('button', { type: 'button', className: 'flybot-reorg-btn', disabled: busy, onClick: onDismiss }, 'Dismiss')), + undone ? null : h('button', { type: 'button', className: 'flybot-reorg-btn', disabled: busy, onClick: onUndo }, tr('Undo')), + h('button', { type: 'button', className: 'flybot-reorg-btn', disabled: busy, onClick: onDismiss }, tr('Dismiss'))), note ? h('div', { className: 'flybot-reorg-note', role: 'alert' }, note) : null) } function makeReorgNotice(flybot) { @@ -479,11 +488,11 @@ window.__ModuleLoader__.load({ // deleting it stays the owner's own click in the Bot menu). function statusOf(bot) { const own = bot?.fields?.['flybot-tree'] ?? {} - if (own.archived) return own.archived.reason === 'merged' && own.archived.intoName ? `archived · merged into ${own.archived.intoName}` : 'archived' - if (own.retired === true) return 'retired' - if (own.idle !== undefined && own.idle !== null) return 'idle' + if (own.archived) return own.archived.reason === 'merged' && own.archived.intoName ? tr('archived · merged into {name}', { name: own.archived.intoName }) : tr('archived') + if (own.retired === true) return tr('retired') + if (own.idle !== undefined && own.idle !== null) return tr('idle') // A Bot that fits no role group while every matching level is full: the sidebar says so instead of passing it off as Chief's child. - if (bot && bot.isMain !== true && !bot.remote && own.retired !== true && own.parent === undefined && own.treeRole === undefined) return 'outside the tree' + if (bot && bot.isMain !== true && !bot.remote && own.retired !== true && own.parent === undefined && own.treeRole === undefined) return tr('outside the tree') return null } function makeStatusTag(statuses) { @@ -506,10 +515,10 @@ window.__ModuleLoader__.load({ }) function ArchivedView({ bots = [], expanded = false, onToggle, openBot }) { if (bots.length === 0) return null - return h('section', { className: 'flybot-tree flybot-tree-archived', 'aria-label': 'Archived bots' }, + return h('section', { className: 'flybot-tree flybot-tree-archived', 'aria-label': tr('Archived bots') }, h('button', { type: 'button', className: 'flybot-tree-head', 'aria-expanded': expanded, onClick: onToggle }, h('span', { className: 'flybot-tree-chev', 'aria-hidden': true }, '▾'), - h('span', { className: 'flybot-tree-title' }, `Archived (${bots.length})`)), + h('span', { className: 'flybot-tree-title' }, tr('Archived ({count})', { count: bots.length }))), expanded ? h('ul', { className: 'flybot-tree-list', role: 'group' }, bots.map(b => { const tag = statusOf(b) diff --git a/plugins/tree/test/sidebar-i18n.test.js b/plugins/tree/test/sidebar-i18n.test.js new file mode 100644 index 000000000..1a42ffd00 --- /dev/null +++ b/plugins/tree/test/sidebar-i18n.test.js @@ -0,0 +1,106 @@ +// #3114 cut 19: the Bot tree's sidebar always draws the Archived Bots group, each row's status +// tag, and the reorganization notice — all English in a zh window while the rest of the sidebar +// followed the window's language. `plugins/tree/client.js` now routes that copy through its own +// `tr()`; this pins both windows and the eleven baseline pins the draws leave behind. The copy is +// read out of the rendered tree, not the source: a string that reaches the section through the +// dictionary and a string merely spelled like the translation look the same in a diff and differ +// here. +import assert from 'node:assert/strict' +import { readFileSync } from 'node:fs' +import { test } from 'node:test' +import { runInNewContext } from 'node:vm' +import { DICTIONARY } from '../../../core/src/client/i18n.js' +import { reactStub, renderToString } from './render.js' + +const zh = DICTIONARY.zh + +// The language a window runs in: `t` answers with the Chinese dictionary for a key it carries and echoes anything else. +const translator = (text, params) => { + const translated = Object.hasOwn(zh, text) ? zh[text] : String(text) + return params ? translated.replace(/\{(\w+)\}/g, (match, name) => (name in params ? String(params[name]) : match)) : translated +} +const zhWindow = { t: translator } +const bareWindow = {} + +// The client is a classic script that registers its factory on `window`, and `tr()` reads +// `__flybot__` off the global object at render time — so the sandbox is that global object. +function loadClient(flybot) { + let mod + const sandbox = { window: { __ModuleLoader__: { load: entry => { mod = entry.factory(() => reactStub) } } }, console, __flybot__: flybot } + sandbox.globalThis = sandbox + runInNewContext(readFileSync(new URL('../client.js', import.meta.url), 'utf8'), sandbox) + return mod +} + +// One archived Bot per reason a row's tag draws — merged into another, archived, retired, idle, and one that fits no role group. +const merged = { id: 'merged', name: 'Old Dev', fields: { 'flybot-tree': { archived: { reason: 'merged', intoName: 'Editor' } } } } +const archived = { id: 'arch', name: 'Old Writer', fields: { 'flybot-tree': { archived: { reason: 'idle' } } } } +const retired = { id: 'ret', name: 'Retired Bot', fields: { 'flybot-tree': { retired: true } } } +const idle = { id: 'idle', name: 'Quiet One', fields: { 'flybot-tree': { idle: 1 } } } +const loose = { id: 'loose', name: 'Loose One', fields: { 'flybot-tree': {} } } + +const archivedHtml = (app, expanded = true) => + renderToString(app.ArchivedView({ bots: [...app.archivedOf([merged, archived, retired]), idle, loose], expanded })) + +// The notice after a reorganization: eight lines with `NOTICE_LINES = 6`, so the card adds the "and 2 more" line. +const run = { id: 'r1', at: Date.UTC(2026, 10, 19, 8, 0), summary: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] } +const undoneRun = { ...run, undone: { kept: ['Chief', 'Editor'] } } +const noticeHtml = (app, notice = run) => renderToString(app.ReorgCard({ run: notice })) + +// What this cut translates: the twelve keys its draws need (Dismiss, Copy invite link and Bot tree already have an entry). +const KEYS = [ + 'Archived bots', 'Archived ({count})', 'Tree reorganized', 'Tree reorganization undone', + 'and {count} more', 'Kept: {names}', 'archived · merged into {name}', 'archived', 'retired', + 'idle', 'outside the tree', 'Undo', +] + +// The eleven pins these draws leave behind, one per draw position: the three baselines and the key each entry holds. +const PINS = [ + ['i18n-plugins', 'Dismiss'], ['i18n-template-draws', 'Archived ({})'], + ['i18n-template-draws', 'Kept: {}'], ['i18n-template-draws', 'and {} more'], + ['i18n-missing-entries', 'Archived bots'], ['i18n-missing-entries', 'Tree reorganized#1'], + ['i18n-missing-entries', 'Tree reorganized#2'], ['i18n-missing-entries', 'Tree reorganization undone'], + ['i18n-missing-entries', 'Undo'], ['i18n-missing-entries', 'archived · merged into {}'], + ['i18n-missing-entries', 'outside the tree'], +] +const baseline = file => JSON.parse(readFileSync(new URL(`../../../core/test/${file}.baseline.json`, import.meta.url), 'utf8')).entries + +test('#3114: a zh window reads the Archived bots group in Chinese', () => { + const html = archivedHtml(loadClient(zhWindow)) + assert.match(html, /aria-label="已归档的 Bot"/, `the section still reads: ${html.slice(0, 140)}`) + assert.match(html, /class="flybot-tree-title">已归档(5)已归档 · 并入 Editor${tag}<`), `the ${tag} tag`) + assert.doesNotMatch(html, /Archived bots|Archived \(|archived · merged|retired|outside the tree/, 'no English tag is left in a zh window') +}) + +test('#3114: a zh window reads the reorganization notice in Chinese', () => { + const app = loadClient(zhWindow) + const html = noticeHtml(app) + assert.match(html, /aria-label="Bot 树已重组"/, `the notice still reads: ${html.slice(0, 160)}`) + assert.match(html, /class="flybot-reorg-title">Bot 树已重组还有 2 条撤销关闭已撤销 Bot 树重组保留:Chief; Editor撤销<|Tree reorganization undone/, 'an undone notice offers no Undo, in either language') +}) + +test('#3114: the tree sidebar keeps no English draw and no translator keeps today\'s English', () => { + assert.deepEqual(KEYS.filter(key => !Object.hasOwn(zh, key)), [], 'every entry has a Chinese value') + + const app = loadClient(bareWindow) + const html = archivedHtml(app) + assert.match(html, /aria-label="Archived bots"/) + assert.match(html, /class="flybot-tree-title">Archived \(5\)archived · merged into Editoroutside the tree${word}<`), `the ${word} draw`) + + const pinned = PINS.filter(([file, key]) => baseline(file).includes(`plugins/tree/client.js:${key}`)) + assert.deepEqual(pinned, [], 'no baseline still pins a draw this cut translated') +})