Skip to content

Commit c72567d

Browse files
docs-botheiskrCopilot
authored
Strip leftover CAT-tool <cN> placeholder tags in translations (#63567)
Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2a265ed commit c72567d

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎src/languages/lib/correct-translation-content.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,6 +1811,8 @@ export function correctTranslatedContentStrings(
18111811
content = content.replaceAll('<b></b>', '')
18121812
content = content.replaceAll('<u></u>', '')
18131813

1814+
content = content.replace(/<\/?c\d+\s*\/?>/g, '')
1815+
18141816
content = content.replace(/(\{%-? )ifversion-([a-z][\w-]*\s*%\})/g, '$1ifversion $2')
18151817

18161818
content = content.replaceAll('["AUTOTITLE]', '"[AUTOTITLE]')

‎src/languages/tests/correct-translation-content.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2998,6 +2998,32 @@ Para más información, consulta "[AUTOTITLE](/path)".
29982998
})
29992999
})
30003000

3001+
describe('universal: strips leftover CAT-tool <cN> placeholder tags', () => {
3002+
test('strips paired <c0>...</c0> tags around text', () => {
3003+
expect(fix('Use the <c0>Create an issue</c0> endpoint.', 'es')).toBe(
3004+
'Use the Create an issue endpoint.',
3005+
)
3006+
})
3007+
3008+
test('strips self-closing <c0/> and unmatched closing tags', () => {
3009+
expect(fix('See the note.<c0/> More text.</c1>', 'ja')).toBe('See the note. More text.')
3010+
})
3011+
3012+
test('strips nested and numbered <cN> tags', () => {
3013+
expect(
3014+
fix(
3015+
'<c1>repositorio especificado octocat/Spoon-Knife<c3>.<c4> Reemplace `REPO-NAME`',
3016+
'es',
3017+
),
3018+
).toBe('repositorio especificado octocat/Spoon-Knife. Reemplace `REPO-NAME`')
3019+
})
3020+
3021+
test('leaves content without <cN> tags unchanged', () => {
3022+
const correct = 'Use the Create an issue endpoint.'
3023+
expect(fix(correct, 'es')).toBe(correct)
3024+
})
3025+
})
3026+
30013027
describe('ja: github-token-scope-descriptions.md per-file fix', () => {
30023028
test('restores the missing endif in the security-events row', () => {
30033029
const broken =

0 commit comments

Comments
 (0)