Merge pull request #2116 from deepseek-harness/worktree/fix-1844-docs-site-chinese-projection

fix(docs): project existing Chinese translations
This commit is contained in:
Yichen Jiang
2026-08-09 21:58:23 +08:00
committed by GitHub
2 changed files with 17 additions and 20 deletions
+9 -8
View File
@@ -251,7 +251,7 @@ describe('rewriteMarkdown', () => {
})
describe('docsPages locale routes', () => {
it('publishes every route in both locales and selects paired sources', () => {
it('publishes every route in both locales and uses every available Chinese counterpart', () => {
const byRoute = new Map(docsPages.map(page => [page.route, page]))
for (const page of docsPages.filter(page => page.locale === 'root')) {
const counterpart = byRoute.get(`en/${page.route}`)
@@ -265,6 +265,11 @@ describe('docsPages locale routes', () => {
} else {
expect(counterpart?.source).toBe(page.source)
expect(counterpart?.contentLocale).toBe(page.contentLocale)
const chineseSource = page.source.replace(/\.md$/, '.zh.md')
expect(
existsSync(resolve(repositoryRoot, chineseSource)),
`${page.route} has a Chinese counterpart but projects English`,
).toBe(false)
}
}
})
@@ -282,20 +287,16 @@ describe('docsPages locale routes', () => {
}
})
it('projects translated subsystem pages while retaining explicit English fallbacks', () => {
it('projects every published subsystem page in Chinese', () => {
const rootPages = docsPages.filter(page => (
page.locale === 'root' && page.route.startsWith('reference/subsystems/')
))
const translated = rootPages.filter(page => page.contentLocale === 'zh-CN')
const fallbacks = rootPages.filter(page => page.contentLocale === 'en-US')
expect(translated).toHaveLength(39)
expect(translated).toHaveLength(42)
expect(translated.every(page => page.source.endsWith('.zh.md'))).toBe(true)
expect(fallbacks.map(page => page.source).sort()).toEqual([
'docs/subsystems/commands.md',
'docs/subsystems/goal.md',
'docs/subsystems/pty.md',
])
expect(fallbacks).toEqual([])
})
it('publishes the Cordis core API under matching locale structures', () => {
+8 -12
View File
@@ -226,7 +226,7 @@ const develop = pairedPages([
},
])
const cordisTutorial = mirroredPages(([
const cordisTutorial = pairedPages(([
['index.md', 'Cordis 教程', 'Cordis tutorial'],
['01-first-plugin.md', '1. 第一个插件', '1. Your first plugin'],
['02-lifecycle-and-effects.md', '2. 生命周期与副作用', '2. Lifecycle and effects'],
@@ -235,10 +235,9 @@ const cordisTutorial = mirroredPages(([
['05-config.md', '5. 配置', '5. Configuration'],
['06-composition-and-hmr.md', '6. 组合与热重载', '6. Composition and HMR'],
['07-into-the-harness.md', '7. 进入 Harness', '7. Into the harness'],
] as const).map(([file, rootLabel, enLabel], order): MirroredPage => ({
] as const).map(([file, rootLabel, enLabel], order): PairedPage => ({
source: `docs/cordis-tutorial/${file}`,
route: `develop/cordis-tutorial/${file}`,
contentLocale: 'en-US',
label: { root: rootLabel, en: enLabel },
sidebar: { root: 'zh-develop', en: 'en-develop' },
section: { root: 'Cordis 教程', en: 'Cordis tutorial' },
@@ -308,12 +307,11 @@ const subsystemsReference = pairedPages(([
})))
const reference = [
...mirroredPages(([
...pairedPages(([
['docs/architecture.md', 'reference/index.md', '架构', 'Architecture', 0],
] as const).map(([source, route, rootLabel, enLabel, order]): MirroredPage => ({
] as const).map(([source, route, rootLabel, enLabel, order]): PairedPage => ({
source,
route,
contentLocale: 'en-US',
label: { root: rootLabel, en: enLabel },
sidebar: { root: 'zh-reference', en: 'en-reference' },
section: { root: '概念', en: 'Concepts' },
@@ -369,28 +367,26 @@ const reference = [
section: { root: 'Cordis API', en: 'Cordis Core API' },
order: order + 5,
}))),
...mirroredPages(([
...pairedPages(([
['goal.md', '目标', 'Goals', 14],
['pty.md', 'PTY 会话', 'PTY sessions', 26],
['commands.md', '命令', 'Human commands', 38],
] as const).map(([file, rootLabel, enLabel, order]): MirroredPage => ({
] as const).map(([file, rootLabel, enLabel, order]): PairedPage => ({
source: `docs/subsystems/${file}`,
route: `reference/subsystems/${file}`,
contentLocale: 'en-US',
label: { root: rootLabel, en: enLabel },
sidebar: { root: 'zh-reference', en: 'en-reference' },
section: { root: '子系统', en: 'Subsystems' },
order,
}))),
...mirroredPages(([
...pairedPages(([
['adding-a-package.md', '新增 Package', 'Adding a package'],
['adding-a-tool.md', '新增 Tool', 'Adding a tool'],
['adding-an-llm-adapter.md', '新增 LLM Adapter', 'Adding an LLM adapter'],
['extension-cookbook.md', '扩展模式', 'Extension patterns'],
] as const).map(([file, rootLabel, enLabel], order): MirroredPage => ({
] as const).map(([file, rootLabel, enLabel], order): PairedPage => ({
source: `docs/cookbook/${file}`,
route: `reference/cookbook/${file}`,
contentLocale: 'en-US',
label: { root: rootLabel, en: enLabel },
sidebar: { root: 'zh-reference', en: 'en-reference' },
section: { root: '开发手册', en: 'Cookbook' },