Skip to content

Commit 64b2674

Browse files
authored
Read the Project plugin's purpose on the Plugins page in the window language (#3114) (#3271)
Written-by: Dev Fixes #3270 Part of #3114 Owner: Dev Reviewer: Reviewer Docs-not-needed: one dictionary key, one test and one changelog fragment; no component or structure change. ## What changed Before: a Chinese window drew the Project plugin's purpose as the English sentence `Run a Project: Project State, its board, its own Chief, its team and its assistant.` on Settings → Plugins. Both faces of that row — the installed one through `SwitchRow.hint` (`core/src/client/settings.js:90`) and the not-installed one through the install hint (`:84`) — already draw `${plugin.package} — ${t(plugin.purpose)}`; the four other plugin purposes had whole-sentence keys in the dictionary and this fifth one had none, so `t()` returned the key itself. After: one whole-sentence key in `core/src/client/i18n.js`, right after `'Run workflow graphs across several Bots.'` — `Run a Project: Project State, its board, its own Chief, its team and its assistant.` → `运行一个项目:Project State、它的看板、它自己的 Chief、它的团队和助手。`. `core/src/client/settings.js` is byte-identical (the draw point stays `t(plugin.purpose)`, twice); no component, no structure, no mapping table. An English window is unchanged (with no locale `t()` returns the key), and the plugin names (`Bot Social` / `Tree` / `Timeline` / `Workflow` / `Project`) are not translated — that is an owner naming decision and a separate cut. `Project State` and `Chief` keep the dictionary's existing English form, as `README.zh.md:79` and `'Project Chief': '项目 Chief'` already do. The new case reads the five `purpose` strings out of `core/src/host/plugins.js` with `/purpose: (['"])((?:(?!\1).)+)\1/g`, so a sixth plugin shipped without a Chinese key fails it too — it guards the class, not only this key. It asserts three things: with no locale the English sentence is still on the page; with a zh locale none of the five English purposes is; and the page reads `运行一个项目`. Hand-written: 3 files / +22/−2 = 24 lines (`core/src/client/i18n.js` +2/−0, `core/test/plugin-installed-faces.test.js` +19/−2, `changelog.d/3114-cut-37-plugin-purpose.fixed.md` +1/−0). Generated, never hand-edited: `core/client.js` (+2) and three patch artifacts (`0001`, `0008`, `files/test/plugin-installed-faces.test.js`). Whole cut: 7 files / +49/−6. ## Verification at the tip Tip SHA: `53adc4b1162a796fb8cdd51242682ba60cca383b` (tree `b9091eb696b8a814ed6f0e7cb7a44bf0be0959c1`, matching the local commit byte for byte) Ran at this tip: ```text $ cd core && TZ=UTC node --test test/plugin-installed-faces.test.js # red first (clean 7f95f0c tree + only the new test): tests 7 / pass 6 / fail 1 # not ok 7 - every plugin purpose reads in the window language # "Run a Project: Project State, its board, its own Chief, its team and its assistant." still reads English in a zh window # at the tip: tests 7 / pass 7 / fail 0 (clean main on the same file: 6 / 6 / 0) $ cd core && TZ=UTC node --test test/i18n.test.js test/i18n-missing-entries.test.js test/i18n-template-draws.test.js test/i18n-plugins.test.js test/i18n-plugins-missing-zh.test.js # tests 41 / pass 41 / fail 0 $ node -e "for (const f of ['i18n-plugins','i18n-template-draws','i18n-missing-entries','i18n-plugins-missing-zh']) console.log(f, require('./core/test/'+f+'.baseline.json').entries.length)" i18n-plugins 12 / i18n-template-draws 9 / i18n-missing-entries 46 / i18n-plugins-missing-zh 2 $ node core/scripts/build-client.mjs --check # rc 0 $ node scripts/ds-bot-patches.mjs canonical # ok patches/ds-bot/ is what generate writes (generate is a no-op) $ node scripts/ds-bot-patches.mjs check # ok pin; ok 10 patches apply cleanly; ok core/ equals ds-bot/ + patches/ds-bot/ $ node .github/scripts/changelog.mjs check # changelog: 18 fragment(s) in changelog.d/ are well formed (main: 17) $ git archive HEAD | tar -x -C <clean dir> && node .github/scripts/check-mojibake.mjs --check mojibake: ok — 0 occurrences of U+FFFD in 1787 text file(s) (rc 0; both trees: main archive 1786) $ ARCH_DOCS_BASE=HEAD~1 node core/scripts/check-arch-docs.mjs # arch-docs: OK (7 changed file(s)), rc 0 $ git diff --shortstat HEAD~1...HEAD # 7 files changed, 49 insertions(+), 6 deletions(-) ``` Two runs sit on a tree I reconstructed here rather than a fresh `git clone`: this box cannot reach `github.com` (only `api.github.com`), so the working copy is a tree whose sha `fc2b56dc00924e47114dd7d20a4cbff79d8378fd` I checked against `GET /repos/ThinkFlowLab/FlyBot/commits/7f95f0cf…` before writing anything. The branch tip was then built with the git data API whose tree sha (`b9091eb6…`) equals the local one, so the pushed bytes are the tested bytes. Red first, on the clean base with the implementation untouched (only the new test in the tree): `# tests 7 / # pass 6 / # fail 1`, `not ok 7`, error text `"Run a Project: Project State, its board, its own Chief, its team and its assistant." still reads English in a zh window`. At the tip the same command is 7/7/0; clean main on the same file is 6/6/0. Risk gate over the seven changed paths, objects carrying `patch` (the shape the PR files API serves): **`T1 0 24 3 4`** — hand-written 24 lines / 3 files, 4 generated paths. The names-only trap reproduced on the same diff (`T0 0 0 7 0`), and the no-`patch` trap reproduces `T3`. Budget leaves 376 lines / 17 files. The forbidden regex (`core/src/host/`, `plugins/`, `.github/`, `scripts/`, `about.js`, `capability-settings.js`, `sidebar.js`, `project-board.js`) hits 0 with the positive control on the same regex hitting 4; `core/src/client/settings.js` is absent from the diff (0) while `grep -c "t(plugin.purpose)"` there is 2; the four `i18n-*.baseline.json` are absent (0); `git diff … core/src/client/i18n.js | grep -c '^-[^-]'` is 0. Not run (and why): the full `TZ=UTC npm run verify`. The shared `core/node_modules` here carries only `esbuild` and a few packages — no `@deepseek-ai/dsh-*` harness and no `jsdom` — so the core suite cannot start on this box, and the brief forbids `npm ci` / `npm run harness`; CI carries the full suite at this tip. Everything runnable here ran at this tip: the affected test file, the five i18n gates, the four baseline counts, the bundle check, the patch checks, changelog, the mojibake byte scan and arch-docs. ## Checkpoint <!-- flybot:checkpoint --> ```json { "pr": 3271, "claim": "Dev", "issue": 3270, "summary": "The Project plugin's row on Settings → Plugins drew its purpose in English in a Chinese window: the draw point already read t(plugin.purpose), but the dictionary had no key for the fifth purpose. One whole-sentence key in core/src/client/i18n.js now reads 运行一个项目:…; no component, no structure and no draw point change, and an English window is unchanged. The new test reads all five purposes from the host catalogue, so a sixth plugin shipped without a key fails it: red first 7/6/1, after the fix 7/7/0. The bundle and the generated patch artifacts were regenerated, never hand-edited.", "files": [ "core/src/client/i18n.js", "core/test/plugin-installed-faces.test.js", "changelog.d/3114-cut-37-plugin-purpose.fixed.md", "core/client.js", "patches/ds-bot/0001-core-fixes.patch", "patches/ds-bot/0008-client-bundle.patch", "patches/ds-bot/files/test/plugin-installed-faces.test.js" ], "checks": { "ran": "plugin-installed-faces 7/6/1 red then 7/7/0 green; five i18n gates 41/41/0; baselines 12/9/46/2; npm run build; ds-bot-patches generate/canonical/check; build-client --check; changelog 18; mojibake 1787; arch-docs OK (7); risk gate T1 0 24 3 4", "result": "green", "at": "53adc4b1162a796fb8cdd51242682ba60cca383b" }, "next": "none — ready for review" } ``` <!-- /flybot:checkpoint -->
1 parent c18bb9f commit 64b2674

7 files changed

Lines changed: 49 additions & 6 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The Project plugin's row on Settings → Plugins now reads its purpose in Chinese instead of English ([#3114](https://github.com/ThinkFlowLab/FlyBot/issues/3114)).

‎core/client.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,8 @@ var ZH = {
15191519
"Run Bots as a tree under a coordinator.": "把 Bot 组织成树,由协调者带队。",
15201520
"Read the team activity as a timeline.": "用时间线查看团队活动。",
15211521
"Run workflow graphs across several Bots.": "跨多个 Bot 运行工作流图。",
1522+
// #3114 cut 37: the Project plugin's purpose; the four above are the other four plugins'.
1523+
"Run a Project: Project State, its board, its own Chief, its team and its assistant.": "运行一个项目:Project State、它的看板、它自己的 Chief、它的团队和助手。",
15221524
"Scheduled tasks · {count}": "定时任务 · {count}",
15231525
"Every day": "每天",
15241526
"Every {count} days": "每 {count} 天",

‎core/src/client/i18n.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,8 @@ const ZH = {
14761476
'Run Bots as a tree under a coordinator.': '把 Bot 组织成树,由协调者带队。',
14771477
'Read the team activity as a timeline.': '用时间线查看团队活动。',
14781478
'Run workflow graphs across several Bots.': '跨多个 Bot 运行工作流图。',
1479+
// #3114 cut 37: the Project plugin's purpose; the four above are the other four plugins'.
1480+
'Run a Project: Project State, its board, its own Chief, its team and its assistant.': '运行一个项目:Project State、它的看板、它自己的 Chief、它的团队和助手。',
14791481
'Scheduled tasks · {count}': '定时任务 · {count}',
14801482
'Every day': '每天',
14811483
'Every {count} days': '每 {count} 天',

‎core/test/plugin-installed-faces.test.js‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
// The Project surfaces themselves are gated by `projectPresent()` (#2877), so this file does
88
// not draw a Projects page for a missing plugin: that answer removes the page instead.
99
import assert from 'node:assert/strict'
10+
import { readFileSync } from 'node:fs'
1011
import { test } from 'node:test'
1112
import { fileURLToPath } from 'node:url'
1213
import { runInNewContext } from 'node:vm'
1314
import { build } from 'esbuild'
1415

1516
const { outputFiles } = await build({
1617
stdin: {
17-
contents: "export { PluginsView, ProjectsList } from './src/client/settings.js'",
18+
contents: "export { PluginsView, ProjectsList } from './src/client/settings.js'\n"
19+
+ "export { DICTIONARY, installLocale } from './src/client/i18n.js'",
1820
resolveDir: fileURLToPath(new URL('..', import.meta.url)),
1921
},
2022
bundle: true, format: 'cjs', platform: 'browser', write: false, logLevel: 'silent',
@@ -55,7 +57,7 @@ runInNewContext(outputFiles[0].text, {
5557
throw new Error(`Unexpected platform module ${name}`)
5658
},
5759
})
58-
const { PluginsView, ProjectsList } = module.exports
60+
const { PluginsView, ProjectsList, DICTIONARY, installLocale } = module.exports
5961

6062
const draw = (node, out = [], depth = 0) => {
6163
if (Array.isArray(node)) { for (const item of node) draw(item, out, depth); return out }
@@ -151,3 +153,18 @@ test('a project whose Chief was created draws no error line (#2869)', () => {
151153
}))
152154
assert.equal(byClass(nodes, 'bt-project-chief-error').length, 0)
153155
})
156+
157+
// #3114 cut 37: the fifth plugin's purpose had no zh key, so a zh window read the English sentence.
158+
const purposes = [...readFileSync(new URL('../src/host/plugins.js', import.meta.url), 'utf8').matchAll(/purpose: (['"])((?:(?!\1).)+)\1/g)].map(match => match[2])
159+
160+
test('#3114 cut 37: every plugin purpose reads in the window language', () => {
161+
const plugins = purposes.map((purpose, at) => plugin({ id: `p${at}`, name: `P${at}`, package: `@flybot/p${at}`, purpose }))
162+
const shown = () => text(draw(PluginsView({ answer: { plugins } })))
163+
for (const purpose of purposes) assert.ok(shown().includes(purpose), `the English window keeps ${purpose}`)
164+
const off = installLocale({ register: () => {}, bind: () => key => DICTIONARY.zh[key] ?? key, getLocale: () => ({ active: 'zh' }) })
165+
try {
166+
const zh = shown()
167+
for (const purpose of purposes) assert.equal(zh.includes(purpose), false, `"${purpose}" still reads English in a zh window`)
168+
assert.match(zh, /运行一个项目/)
169+
} finally { off() }
170+
})

‎patches/ds-bot/0001-core-fixes.patch‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1828,7 +1828,7 @@ diff --git a/src/client/i18n.js b/src/client/i18n.js
18281828
'Model call': '模型调用',
18291829
'This window': '这个窗口',
18301830
'Error log': '错误日志',
1831-
@@ -771,12 +771,33 @@ const ZH = {
1831+
@@ -771,12 +771,35 @@ const ZH = {
18321832
'Add at least one more Bot': '再至少添加一个 Bot',
18331833
Members: '成员',
18341834
// Connectors and scheduled tasks
@@ -1847,6 +1847,8 @@ diff --git a/src/client/i18n.js b/src/client/i18n.js
18471847
+ 'Run Bots as a tree under a coordinator.': '把 Bot 组织成树,由协调者带队。',
18481848
+ 'Read the team activity as a timeline.': '用时间线查看团队活动。',
18491849
+ 'Run workflow graphs across several Bots.': '跨多个 Bot 运行工作流图。',
1850+
+ // #3114 cut 37: the Project plugin's purpose; the four above are the other four plugins'.
1851+
+ 'Run a Project: Project State, its board, its own Chief, its team and its assistant.': '运行一个项目:Project State、它的看板、它自己的 Chief、它的团队和助手。',
18501852
+ 'Scheduled tasks · {count}': '定时任务 · {count}',
18511853
'Every day': '每天',
18521854
'Every {count} days': '每 {count} 天',

‎patches/ds-bot/0008-client-bundle.patch‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ diff --git a/client.js b/client.js
10811081
"Model call": "模型调用",
10821082
"This window": "这个窗口",
10831083
"Error log": "错误日志",
1084-
@@ -821,12 +821,33 @@ var ZH = {
1084+
@@ -821,12 +821,35 @@ var ZH = {
10851085
"Add at least one more Bot": "再至少添加一个 Bot",
10861086
Members: "成员",
10871087
// Connectors and scheduled tasks
@@ -1100,6 +1100,8 @@ diff --git a/client.js b/client.js
11001100
+ "Run Bots as a tree under a coordinator.": "把 Bot 组织成树,由协调者带队。",
11011101
+ "Read the team activity as a timeline.": "用时间线查看团队活动。",
11021102
+ "Run workflow graphs across several Bots.": "跨多个 Bot 运行工作流图。",
1103+
+ // #3114 cut 37: the Project plugin's purpose; the four above are the other four plugins'.
1104+
+ "Run a Project: Project State, its board, its own Chief, its team and its assistant.": "运行一个项目:Project State、它的看板、它自己的 Chief、它的团队和助手。",
11031105
+ "Scheduled tasks · {count}": "定时任务 · {count}",
11041106
"Every day": "每天",
11051107
"Every {count} days": "每 {count} 天",

‎patches/ds-bot/files/test/plugin-installed-faces.test.js‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
// The Project surfaces themselves are gated by `projectPresent()` (#2877), so this file does
88
// not draw a Projects page for a missing plugin: that answer removes the page instead.
99
import assert from 'node:assert/strict'
10+
import { readFileSync } from 'node:fs'
1011
import { test } from 'node:test'
1112
import { fileURLToPath } from 'node:url'
1213
import { runInNewContext } from 'node:vm'
1314
import { build } from 'esbuild'
1415

1516
const { outputFiles } = await build({
1617
stdin: {
17-
contents: "export { PluginsView, ProjectsList } from './src/client/settings.js'",
18+
contents: "export { PluginsView, ProjectsList } from './src/client/settings.js'\n"
19+
+ "export { DICTIONARY, installLocale } from './src/client/i18n.js'",
1820
resolveDir: fileURLToPath(new URL('..', import.meta.url)),
1921
},
2022
bundle: true, format: 'cjs', platform: 'browser', write: false, logLevel: 'silent',
@@ -55,7 +57,7 @@ runInNewContext(outputFiles[0].text, {
5557
throw new Error(`Unexpected platform module ${name}`)
5658
},
5759
})
58-
const { PluginsView, ProjectsList } = module.exports
60+
const { PluginsView, ProjectsList, DICTIONARY, installLocale } = module.exports
5961

6062
const draw = (node, out = [], depth = 0) => {
6163
if (Array.isArray(node)) { for (const item of node) draw(item, out, depth); return out }
@@ -151,3 +153,18 @@ test('a project whose Chief was created draws no error line (#2869)', () => {
151153
}))
152154
assert.equal(byClass(nodes, 'bt-project-chief-error').length, 0)
153155
})
156+
157+
// #3114 cut 37: the fifth plugin's purpose had no zh key, so a zh window read the English sentence.
158+
const purposes = [...readFileSync(new URL('../src/host/plugins.js', import.meta.url), 'utf8').matchAll(/purpose: (['"])((?:(?!\1).)+)\1/g)].map(match => match[2])
159+
160+
test('#3114 cut 37: every plugin purpose reads in the window language', () => {
161+
const plugins = purposes.map((purpose, at) => plugin({ id: `p${at}`, name: `P${at}`, package: `@flybot/p${at}`, purpose }))
162+
const shown = () => text(draw(PluginsView({ answer: { plugins } })))
163+
for (const purpose of purposes) assert.ok(shown().includes(purpose), `the English window keeps ${purpose}`)
164+
const off = installLocale({ register: () => {}, bind: () => key => DICTIONARY.zh[key] ?? key, getLocale: () => ({ active: 'zh' }) })
165+
try {
166+
const zh = shown()
167+
for (const purpose of purposes) assert.equal(zh.includes(purpose), false, `"${purpose}" still reads English in a zh window`)
168+
assert.match(zh, /运行一个项目/)
169+
} finally { off() }
170+
})

0 commit comments

Comments
 (0)