Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/3114-cut-37-plugin-purpose.fixed.md
Original file line number Diff line number Diff line change
@@ -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)).
2 changes: 2 additions & 0 deletions core/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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} 天",
Expand Down
2 changes: 2 additions & 0 deletions core/src/client/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -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} 天',
Expand Down
21 changes: 19 additions & 2 deletions core/test/plugin-installed-faces.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
// 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'
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',
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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() }
})
4 changes: 3 additions & 1 deletion patches/ds-bot/0001-core-fixes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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} 天',
Expand Down
4 changes: 3 additions & 1 deletion patches/ds-bot/0008-client-bundle.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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} 天",
Expand Down
21 changes: 19 additions & 2 deletions patches/ds-bot/files/test/plugin-installed-faces.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
// 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'
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',
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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() }
})
Loading