Skip to content

Commit 43f709d

Browse files
docs-botCopilotheiskr
authored
Fix padded octicon names from French guillemets in translation corrector (#63716)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com> Copilot-Session: 487ebd54-80b0-4d3d-bb7c-95f39bec45f3
1 parent b4af924 commit 43f709d

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,18 @@ export function correctTranslatedContentStrings(
16111611
return match.replace(/[«»“”„]/g, '"').replace(/[‘’‚]/g, "'")
16121612
})
16131613

1614+
// French « check » becomes " check " after quote normalization.
1615+
content = content.replace(
1616+
/\{%(-?)\s*octicon\s+"\s*([\w-]+)\s*"([^%]*?)(-?)%\}/g,
1617+
(_m, o, name, rest, c) => {
1618+
const fixedRest = rest.replace(
1619+
/(^|\s)(aria-label|aria-hidden|height|width|class)="\s*([^"]*?[^"\s])\s*"/g,
1620+
'$1$2="$3"',
1621+
)
1622+
return `{%${o} octicon "${name}"${fixedRest.replace(/\s*$/, ' ')}${c}%}`
1623+
},
1624+
)
1625+
16141626
content = content.replace(
16151627
/\{%(-?)\s+(ifversion|elsif|if)\s+([^%]*?)\s*(-?)%\}/g,
16161628
(_m, dashOpen, tag, body, dashClose) =>

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3379,4 +3379,30 @@ Para más información, consulta "[AUTOTITLE](/path)".
33793379
).toBe(broken)
33803380
})
33813381
})
3382+
3383+
describe('octicon with French guillemets', () => {
3384+
test('fr: trims padding left by « check » after quote normalization', () => {
3385+
expect(fix('{% octicon « check » aria-label="Included » %}', 'fr')).toBe(
3386+
'{% octicon "check" aria-label="Included" %}',
3387+
)
3388+
expect(fix('{% octicon « x » aria-label="Non inclus" %}', 'fr')).toBe(
3389+
'{% octicon "x" aria-label="Non inclus" %}',
3390+
)
3391+
})
3392+
3393+
test('fr: leaves a correct octicon unchanged', () => {
3394+
const ok = '{% octicon "check" aria-label="Included" %}'
3395+
expect(fix(ok, 'fr')).toBe(ok)
3396+
})
3397+
3398+
test('leaves padded values on other attributes unchanged', () => {
3399+
const custom = '{% octicon "x" data-aria-label=" a " myclass=" b " title=" c " %}'
3400+
expect(fix(custom, 'fr')).toBe(custom)
3401+
})
3402+
3403+
test('leaves whitespace-only attribute values unchanged', () => {
3404+
const blank = '{% octicon "x" class=" " width="64" aria-label="Supported" %}'
3405+
expect(fix(blank, 'fr')).toBe(blank)
3406+
})
3407+
})
33823408
})

0 commit comments

Comments
 (0)