From 99c562657b6af35c383b5f77084854696116030c Mon Sep 17 00:00:00 2001 From: docs-bot <77750099+docs-bot@users.noreply.github.com> Date: Fri, 18 Sep 2026 20:58:00 +0000 Subject: [PATCH] Add 5 translation correction patterns for malformed Liquid tag reordering (#63355) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Kevin Heis --- .../lib/correct-translation-content.ts | 72 +++++++++++++++++++ .../tests/correct-translation-content.ts | 66 +++++++++++++++++ 2 files changed, 138 insertions(+) diff --git a/src/languages/lib/correct-translation-content.ts b/src/languages/lib/correct-translation-content.ts index 9d615af94351..f76a8904d9fe 100644 --- a/src/languages/lib/correct-translation-content.ts +++ b/src/languages/lib/correct-translation-content.ts @@ -140,6 +140,25 @@ export function correctTranslatedContentStrings( // duplicating the same rule per language. content = content.replace(/\{%(-?)data (variables|reusables)\./g, '{%$1 data $2.') + // securely-using-pull_request_target.md: translators in several languages + // (de, es, fr, ko, pt) reordered the inline Liquid tags to match their + // language's word order, moving `{% endif %}` before the + // `{% ifversion default-pull-req-target-policy %}` that opens the block, + // leaving the tag never closed (`tag {% ifversion + // default-pull-req-target-policy %} not closed`). English source is + // `...opt out of the {% ifversion default-pull-req-target-policy %}default + // event policy and {% endif %}\`actions/checkout\` protection.` Swap the + // tag pair back into the correct order, keeping the translated text + // between them intact. This tag name is unique to this construct, so the + // fix is shared across the affected languages but scoped to this page to + // avoid reordering valid adjacent conditionals elsewhere. + if (context.relativePath?.endsWith('/securely-using-pull_request_target.md')) { + content = content.replace( + /\{% endif %\}([^{}]*?)\{% ifversion default-pull-req-target-policy %\}/g, + '{% ifversion default-pull-req-target-policy %}$1{% endif %}', + ) + } + // --- Per-language fixes (es, ja, pt, zh, ru, fr, ko, de) --- if (context.code === 'es') { @@ -340,6 +359,19 @@ export function correctTranslatedContentStrings( content = content.replace(/^\{%-?\s*elsif\s+/, '{% ifversion ') } + // get-started/start-your-journey/connecting-to-your-code-locally.md: the + // translator dropped the closing `{% endif %}` after the "Sign in to + // GitHub Enterprise" branch, leaving `{% ifversion fpt or ghec %}` never + // closed (`tag {% ifversion fpt or ghec %} not closed`). English: + // `...click {% ifversion fpt or ghec %}**Sign in to + // {% data variables.product.prodname_dotcom_the_website %}**{% else %} + // **Sign in to {% data variables.product.prodname_enterprise %}** + // {% endif %}.` + content = content.replaceAll( + '{% ifversion fpt or ghec %}{% data variables.product.prodname_dotcom_the_website %}****{% else %}.{% data variables.product.prodname_enterprise %}', + '{% ifversion fpt or ghec %}{% data variables.product.prodname_dotcom_the_website %}****{% else %}{% data variables.product.prodname_enterprise %}{% endif %}.', + ) + // enforcing-repository-management-policies-in-your-enterprise.md: the // second of two near-identical "Under 'Repository...invitations'" steps // dropped the `{% endif %}` closing the `{% ifversion ghec %}...{% elsif @@ -725,6 +757,18 @@ export function correctTranslatedContentStrings( // not found`). content = content.replace(/\{%(-?)\s*roleColumns\s*=\s*/g, '{%$1 assign roleColumns = ') + // copilot/reference/copilot-feature-matrix.md: the translator reordered + // the inline Liquid tags to match Japanese word order, moving + // `{% endif %}` before the `{% if ideEntry.versionType == "extension" %}` + // that opens the block (repeated 6 times, once per IDE table). English: + // `...across recent versions of the {% if ideEntry.versionType == + // "extension" %}{% data variables.copilot.copilot_extension %} for the + // {% endif %}IDE.` Swap the tags back into the correct order. + content = content.replaceAll( + '次の表は、{% endif %}IDE の{% if ideEntry.versionType == "extension" %}{% data variables.copilot.copilot_extension %}の', + '次の表は、IDE の{% if ideEntry.versionType == "extension" %}{% data variables.copilot.copilot_extension %}{% endif %}の', + ) + // [SCRAPE] data/reusables/actions/github-token-scope-descriptions.md // (also included by data/reusables/actions/jobs/section-assigning-permissions-to-jobs.md): // the `{% ifversion vulnerability-alerts-permission %}...{% else %}...{% endif %}` @@ -1025,6 +1069,18 @@ export function correctTranslatedContentStrings( '1. Em "Nome de usuário, organização ou nome da empresa {% else %}nome de usuário ou nome da organização do {% data variables.product.prodname_dotcom %} {% ifversion fpt or enterprise-apps-public-beta %} do novo proprietário",{% endif %} digite o nome da conta para a qual você deseja transferir o {% data variables.product.prodname_github_app %}.', '1. Em "{% ifversion fpt or enterprise-apps-public-beta %}Nome de usuário, organização ou nome da empresa{% else %}nome de usuário ou nome da organização{% endif %} do {% data variables.product.prodname_dotcom %} do novo proprietário", digite o nome da conta para a qual você deseja transferir o {% data variables.product.prodname_github_app %}.', ) + + // copilot/reference/copilot-feature-matrix.md: the translator reordered + // the inline Liquid tags to match Portuguese word order, moving + // `{% endif %}` before the `{% if ideEntry.versionType == "extension" %}` + // that opens the block (repeated 6 times, once per IDE table). English: + // `...across recent versions of the {% if ideEntry.versionType == + // "extension" %}{% data variables.copilot.copilot_extension %} for the + // {% endif %}IDE.` Swap the tags back into the correct order. + content = content.replaceAll( + 'do {% endif %}{% if ideEntry.versionType == "extension" %}{% data variables.copilot.copilot_extension %} IDE.', + 'do {% if ideEntry.versionType == "extension" %}{% data variables.copilot.copilot_extension %}{% endif %} IDE.', + ) } if (context.code === 'zh') { @@ -1917,6 +1973,22 @@ export function correctTranslatedContentStrings( '{% reusable (fr) classroom.vous-pouvez-créer-une-pull-request-pour-retour %}', '{% data reusables.classroom.you-can-create-a-pull-request-for-feedback %}', ) + + // data/reusables/repositories/repository-branches.md: the translator + // reordered the inline Liquid tags to match French word order, moving + // `{% endif %}` before the `{% elsif ghes %}` branch it should close, + // leaving `{% ifversion fpt or ghec %}` never closed (`tag + // {% ifversion fpt or ghec %} not closed`) and orphaning the `»` + // (closing guillemet) outside the conditional. This reusable is included + // by managing-a-branch-protection-rule.md and + // converting-branch-protections-to-rulesets.md. English: `In the + // {% ifversion fpt or ghec %} "Code, planning, and automation" + // {% elsif ghes %} "Code and automation"{% endif %} section of the + // sidebar...` + content = content.replaceAll( + 'automatisation{% endif %} »{% elsif ghes %} de la barre latérale', + 'automatisation »{% elsif ghes %}{% endif %} de la barre latérale', + ) } if (context.code === 'ko') { diff --git a/src/languages/tests/correct-translation-content.ts b/src/languages/tests/correct-translation-content.ts index 4eb1a3ba321c..843422219361 100644 --- a/src/languages/tests/correct-translation-content.ts +++ b/src/languages/tests/correct-translation-content.ts @@ -3365,4 +3365,70 @@ Para más información, consulta "[AUTOTITLE](/path)". expect(fix(fixed, 'ko')).toBe(fixed) }) }) + + describe('securely-using-pull_request_target.md per-file fix', () => { + const context = { + relativePath: 'actions/reference/security/securely-using-pull_request_target.md', + skipOrphanStripping: true, + } + + test('swaps a reordered endif/ifversion default-pull-req-target-policy pair back into order', () => { + const broken = + 'you can opt out of the {% endif %}default event policy and {% ifversion default-pull-req-target-policy %}`actions/checkout` protection.' + const fixed = + 'you can opt out of the {% ifversion default-pull-req-target-policy %}default event policy and {% endif %}`actions/checkout` protection.' + for (const code of ['es', 'pt', 'fr', 'ko', 'de']) { + expect(correctTranslatedContentStrings(broken, '', { ...context, code })).toBe(fixed) + expect(correctTranslatedContentStrings(fixed, '', { ...context, code })).toBe(fixed) + } + }) + + test('does not touch the same feature in other files', () => { + const untouched = + '{% ifversion ghec %}foo{% endif %} bar {% ifversion default-pull-req-target-policy %}baz{% endif %}' + expect(fix(untouched, 'es')).toBe(untouched) + }) + }) + + describe('connecting-to-your-code-locally.md per-file fix', () => { + test('es: restores the dropped endif after the Sign in step', () => { + const broken = + '{% ifversion fpt or ghec %}{% data variables.product.prodname_dotcom_the_website %}****{% else %}.{% data variables.product.prodname_enterprise %}' + const fixed = + '{% ifversion fpt or ghec %}{% data variables.product.prodname_dotcom_the_website %}****{% else %}{% data variables.product.prodname_enterprise %}{% endif %}.' + expect(fix(broken, 'es')).toBe(fixed) + expect(fix(fixed, 'es')).toBe(fixed) + }) + }) + + describe('copilot-feature-matrix.md per-file fix', () => { + test('ja: swaps the reordered endif/if ideEntry.versionType pair back into order', () => { + const broken = + '次の表は、{% endif %}IDE の{% if ideEntry.versionType == "extension" %}{% data variables.copilot.copilot_extension %}の最新バージョンで' + const fixed = + '次の表は、IDE の{% if ideEntry.versionType == "extension" %}{% data variables.copilot.copilot_extension %}{% endif %}の最新バージョンで' + expect(fix(broken, 'ja')).toBe(fixed) + expect(fix(fixed, 'ja')).toBe(fixed) + }) + + test('pt: swaps the reordered endif/if ideEntry.versionType pair back into order', () => { + const broken = + 'suporte em versões recentes do {% endif %}{% if ideEntry.versionType == "extension" %}{% data variables.copilot.copilot_extension %} IDE.' + const fixed = + 'suporte em versões recentes do {% if ideEntry.versionType == "extension" %}{% data variables.copilot.copilot_extension %}{% endif %} IDE.' + expect(fix(broken, 'pt')).toBe(fixed) + expect(fix(fixed, 'pt')).toBe(fixed) + }) + }) + + describe('data/reusables/repositories/repository-branches.md per-file fix', () => { + test('fr: moves the misplaced endif after the elsif branch it should close', () => { + const broken = + '1. Dans la{% ifversion fpt or ghec %} section « Code, planification et automatisation{% endif %} »{% elsif ghes %} de la barre latérale, cliquez sur **Branches**.' + const fixed = + '1. Dans la{% ifversion fpt or ghec %} section « Code, planification et automatisation »{% elsif ghes %}{% endif %} de la barre latérale, cliquez sur **Branches**.' + expect(fix(broken, 'fr')).toBe(fixed) + expect(fix(fixed, 'fr')).toBe(fixed) + }) + }) })