From f6fb0740366f30fac5b6a4fe795ef8de8240f31a Mon Sep 17 00:00:00 2001 From: pku-xht Date: Tue, 18 Aug 2026 20:19:38 +0800 Subject: [PATCH] refactor(i18n): remove obsolete link lookup --- scripts/translation-pairing.spec.ts | 15 +++++++++------ scripts/translation-pairing.ts | 12 ------------ 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/scripts/translation-pairing.spec.ts b/scripts/translation-pairing.spec.ts index ed24593720..3fb8bb4a84 100644 --- a/scripts/translation-pairing.spec.ts +++ b/scripts/translation-pairing.spec.ts @@ -20,7 +20,6 @@ import { blobHash, isTranslationScopeFile, languageSwitcherTargets, - linksTo, pairAnchorOfArgument, parseTranslationMarkdown, parseTranslationPairingCliArgs, @@ -187,17 +186,21 @@ describe('translation pairing switchers', () => { const targets = languageSwitcherTargets('python/sdk/README.zh.md') const canonicalMarkdown = '# README\n\nEnglish | [中文](https://github.com/deepseek-ai/deepseek-harness/blob/master/python/sdk/README.zh.md)\n' const canonical = parseTranslationMarkdown(canonicalMarkdown) - const wrongPath = parseTranslationMarkdown( - '[中文](https://github.com/deepseek-ai/deepseek-harness/blob/master/other/README.zh.md)', - ) + const wrongMarkdown = '# README\n\nEnglish | [中文](https://github.com/deepseek-ai/deepseek-harness/blob/master/other/README.zh.md)\n' + const wrongPath = parseTranslationMarkdown(wrongMarkdown) - expect(linksTo(canonical, targets)).toBe(true) expect(translationStructureSignature(canonical, targets, { repoRoot: process.cwd(), sourcePath: 'python/sdk/README.md', markdown: canonicalMarkdown, }).links).toEqual([]) - expect(linksTo(wrongPath, targets)).toBe(false) + expect(translationStructureSignature(wrongPath, targets, { + repoRoot: process.cwd(), + sourcePath: 'python/sdk/README.md', + markdown: wrongMarkdown, + }).links).toEqual([ + 'https://github.com/deepseek-ai/deepseek-harness/blob/master/other/README.zh.md', + ]) }) it('excludes only the header switcher from the structural links', () => { diff --git a/scripts/translation-pairing.ts b/scripts/translation-pairing.ts index e8890b773e..35e7155fa8 100644 --- a/scripts/translation-pairing.ts +++ b/scripts/translation-pairing.ts @@ -314,18 +314,6 @@ export function languageSwitcherTargets(counterpart: string): string[] { return [basename(counterpart), `${PUBLIC_REPOSITORY_BLOB_ROOT}${counterpart}`] } -/** Whether the tree contains a link to any accepted target. */ -export function linksTo(tree: Nodes, targets: string | readonly string[]): boolean { - const accepted = new Set(typeof targets === 'string' ? [targets] : targets) - let found = false - const visit = (node: Nodes): void => { - if (node.type === 'link' && accepted.has(node.url)) found = true - if ('children' in node) for (const child of node.children) visit(child) - } - visit(tree) - return found -} - /** Generated English sources cannot carry a switcher without making their generator stale. */ export function requiresSourceLanguageSwitcher(source: string): boolean { return ![