diff --git a/changelog.d/3114-cut-37-plugin-purpose.fixed.md b/changelog.d/3114-cut-37-plugin-purpose.fixed.md new file mode 100644 index 000000000..4002f0025 --- /dev/null +++ b/changelog.d/3114-cut-37-plugin-purpose.fixed.md @@ -0,0 +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)). diff --git a/core/client.js b/core/client.js index 159f7e1d6..079761269 100644 --- a/core/client.js +++ b/core/client.js @@ -1519,6 +1519,8 @@ var ZH = { "Run Bots as a tree under a coordinator.": "把 Bot 组织成树,由协调者带队。", "Read the team activity as a timeline.": "用时间线查看团队活动。", "Run workflow graphs across several Bots.": "跨多个 Bot 运行工作流图。", + // #3114 cut 37: the Project plugin's purpose; the four above are the other four plugins'. + "Run a Project: Project State, its board, its own Chief, its team and its assistant.": "运行一个项目:Project State、它的看板、它自己的 Chief、它的团队和助手。", "Scheduled tasks · {count}": "定时任务 · {count}", "Every day": "每天", "Every {count} days": "每 {count} 天", diff --git a/core/src/client/i18n.js b/core/src/client/i18n.js index 3ec14522d..90714c873 100644 --- a/core/src/client/i18n.js +++ b/core/src/client/i18n.js @@ -1476,6 +1476,8 @@ const ZH = { 'Run Bots as a tree under a coordinator.': '把 Bot 组织成树,由协调者带队。', 'Read the team activity as a timeline.': '用时间线查看团队活动。', 'Run workflow graphs across several Bots.': '跨多个 Bot 运行工作流图。', + // #3114 cut 37: the Project plugin's purpose; the four above are the other four plugins'. + 'Run a Project: Project State, its board, its own Chief, its team and its assistant.': '运行一个项目:Project State、它的看板、它自己的 Chief、它的团队和助手。', 'Scheduled tasks · {count}': '定时任务 · {count}', 'Every day': '每天', 'Every {count} days': '每 {count} 天', diff --git a/core/test/plugin-installed-faces.test.js b/core/test/plugin-installed-faces.test.js index 1717d755b..4355ac60a 100644 --- a/core/test/plugin-installed-faces.test.js +++ b/core/test/plugin-installed-faces.test.js @@ -7,6 +7,7 @@ // The Project surfaces themselves are gated by `projectPresent()` (#2877), so this file does // not draw a Projects page for a missing plugin: that answer removes the page instead. import assert from 'node:assert/strict' +import { readFileSync } from 'node:fs' import { test } from 'node:test' import { fileURLToPath } from 'node:url' import { runInNewContext } from 'node:vm' @@ -14,7 +15,8 @@ import { build } from 'esbuild' const { outputFiles } = await build({ stdin: { - contents: "export { PluginsView, ProjectsList } from './src/client/settings.js'", + contents: "export { PluginsView, ProjectsList } from './src/client/settings.js'\n" + + "export { DICTIONARY, installLocale } from './src/client/i18n.js'", resolveDir: fileURLToPath(new URL('..', import.meta.url)), }, bundle: true, format: 'cjs', platform: 'browser', write: false, logLevel: 'silent', @@ -55,7 +57,7 @@ runInNewContext(outputFiles[0].text, { throw new Error(`Unexpected platform module ${name}`) }, }) -const { PluginsView, ProjectsList } = module.exports +const { PluginsView, ProjectsList, DICTIONARY, installLocale } = module.exports const draw = (node, out = [], depth = 0) => { 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)', () => { })) assert.equal(byClass(nodes, 'bt-project-chief-error').length, 0) }) + +// #3114 cut 37: the fifth plugin's purpose had no zh key, so a zh window read the English sentence. +const purposes = [...readFileSync(new URL('../src/host/plugins.js', import.meta.url), 'utf8').matchAll(/purpose: (['"])((?:(?!\1).)+)\1/g)].map(match => match[2]) + +test('#3114 cut 37: every plugin purpose reads in the window language', () => { + const plugins = purposes.map((purpose, at) => plugin({ id: `p${at}`, name: `P${at}`, package: `@flybot/p${at}`, purpose })) + const shown = () => text(draw(PluginsView({ answer: { plugins } }))) + for (const purpose of purposes) assert.ok(shown().includes(purpose), `the English window keeps ${purpose}`) + const off = installLocale({ register: () => {}, bind: () => key => DICTIONARY.zh[key] ?? key, getLocale: () => ({ active: 'zh' }) }) + try { + const zh = shown() + for (const purpose of purposes) assert.equal(zh.includes(purpose), false, `"${purpose}" still reads English in a zh window`) + assert.match(zh, /运行一个项目/) + } finally { off() } +}) diff --git a/patches/ds-bot/0001-core-fixes.patch b/patches/ds-bot/0001-core-fixes.patch index eaa4227c6..e7217d38d 100644 --- a/patches/ds-bot/0001-core-fixes.patch +++ b/patches/ds-bot/0001-core-fixes.patch @@ -1828,7 +1828,7 @@ diff --git a/src/client/i18n.js b/src/client/i18n.js 'Model call': '模型调用', 'This window': '这个窗口', 'Error log': '错误日志', -@@ -771,12 +771,33 @@ const ZH = { +@@ -771,12 +771,35 @@ const ZH = { 'Add at least one more Bot': '再至少添加一个 Bot', Members: '成员', // Connectors and scheduled tasks @@ -1847,6 +1847,8 @@ diff --git a/src/client/i18n.js b/src/client/i18n.js + 'Run Bots as a tree under a coordinator.': '把 Bot 组织成树,由协调者带队。', + 'Read the team activity as a timeline.': '用时间线查看团队活动。', + 'Run workflow graphs across several Bots.': '跨多个 Bot 运行工作流图。', ++ // #3114 cut 37: the Project plugin's purpose; the four above are the other four plugins'. ++ 'Run a Project: Project State, its board, its own Chief, its team and its assistant.': '运行一个项目:Project State、它的看板、它自己的 Chief、它的团队和助手。', + 'Scheduled tasks · {count}': '定时任务 · {count}', 'Every day': '每天', 'Every {count} days': '每 {count} 天', diff --git a/patches/ds-bot/0008-client-bundle.patch b/patches/ds-bot/0008-client-bundle.patch index 3d85c63ed..43d2a63b5 100644 --- a/patches/ds-bot/0008-client-bundle.patch +++ b/patches/ds-bot/0008-client-bundle.patch @@ -1081,7 +1081,7 @@ diff --git a/client.js b/client.js "Model call": "模型调用", "This window": "这个窗口", "Error log": "错误日志", -@@ -821,12 +821,33 @@ var ZH = { +@@ -821,12 +821,35 @@ var ZH = { "Add at least one more Bot": "再至少添加一个 Bot", Members: "成员", // Connectors and scheduled tasks @@ -1100,6 +1100,8 @@ diff --git a/client.js b/client.js + "Run Bots as a tree under a coordinator.": "把 Bot 组织成树,由协调者带队。", + "Read the team activity as a timeline.": "用时间线查看团队活动。", + "Run workflow graphs across several Bots.": "跨多个 Bot 运行工作流图。", ++ // #3114 cut 37: the Project plugin's purpose; the four above are the other four plugins'. ++ "Run a Project: Project State, its board, its own Chief, its team and its assistant.": "运行一个项目:Project State、它的看板、它自己的 Chief、它的团队和助手。", + "Scheduled tasks · {count}": "定时任务 · {count}", "Every day": "每天", "Every {count} days": "每 {count} 天", diff --git a/patches/ds-bot/files/test/plugin-installed-faces.test.js b/patches/ds-bot/files/test/plugin-installed-faces.test.js index 1717d755b..4355ac60a 100644 --- a/patches/ds-bot/files/test/plugin-installed-faces.test.js +++ b/patches/ds-bot/files/test/plugin-installed-faces.test.js @@ -7,6 +7,7 @@ // The Project surfaces themselves are gated by `projectPresent()` (#2877), so this file does // not draw a Projects page for a missing plugin: that answer removes the page instead. import assert from 'node:assert/strict' +import { readFileSync } from 'node:fs' import { test } from 'node:test' import { fileURLToPath } from 'node:url' import { runInNewContext } from 'node:vm' @@ -14,7 +15,8 @@ import { build } from 'esbuild' const { outputFiles } = await build({ stdin: { - contents: "export { PluginsView, ProjectsList } from './src/client/settings.js'", + contents: "export { PluginsView, ProjectsList } from './src/client/settings.js'\n" + + "export { DICTIONARY, installLocale } from './src/client/i18n.js'", resolveDir: fileURLToPath(new URL('..', import.meta.url)), }, bundle: true, format: 'cjs', platform: 'browser', write: false, logLevel: 'silent', @@ -55,7 +57,7 @@ runInNewContext(outputFiles[0].text, { throw new Error(`Unexpected platform module ${name}`) }, }) -const { PluginsView, ProjectsList } = module.exports +const { PluginsView, ProjectsList, DICTIONARY, installLocale } = module.exports const draw = (node, out = [], depth = 0) => { 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)', () => { })) assert.equal(byClass(nodes, 'bt-project-chief-error').length, 0) }) + +// #3114 cut 37: the fifth plugin's purpose had no zh key, so a zh window read the English sentence. +const purposes = [...readFileSync(new URL('../src/host/plugins.js', import.meta.url), 'utf8').matchAll(/purpose: (['"])((?:(?!\1).)+)\1/g)].map(match => match[2]) + +test('#3114 cut 37: every plugin purpose reads in the window language', () => { + const plugins = purposes.map((purpose, at) => plugin({ id: `p${at}`, name: `P${at}`, package: `@flybot/p${at}`, purpose })) + const shown = () => text(draw(PluginsView({ answer: { plugins } }))) + for (const purpose of purposes) assert.ok(shown().includes(purpose), `the English window keeps ${purpose}`) + const off = installLocale({ register: () => {}, bind: () => key => DICTIONARY.zh[key] ?? key, getLocale: () => ({ active: 'zh' }) }) + try { + const zh = shown() + for (const purpose of purposes) assert.equal(zh.includes(purpose), false, `"${purpose}" still reads English in a zh window`) + assert.match(zh, /运行一个项目/) + } finally { off() } +})