Skip to content

Commit 27965d1

Browse files
authored
Merge pull request #45954 from github/repo-sync
Repo sync
2 parents 1fa3a6d + 99c5626 commit 27965d1

2 files changed

Lines changed: 138 additions & 0 deletions

File tree

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

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,25 @@ export function correctTranslatedContentStrings(
140140
// duplicating the same rule per language.
141141
content = content.replace(/\{%(-?)data (variables|reusables)\./g, '{%$1 data $2.')
142142

143+
// securely-using-pull_request_target.md: translators in several languages
144+
// (de, es, fr, ko, pt) reordered the inline Liquid tags to match their
145+
// language's word order, moving `{% endif %}` before the
146+
// `{% ifversion default-pull-req-target-policy %}` that opens the block,
147+
// leaving the tag never closed (`tag {% ifversion
148+
// default-pull-req-target-policy %} not closed`). English source is
149+
// `...opt out of the {% ifversion default-pull-req-target-policy %}default
150+
// event policy and {% endif %}\`actions/checkout\` protection.` Swap the
151+
// tag pair back into the correct order, keeping the translated text
152+
// between them intact. This tag name is unique to this construct, so the
153+
// fix is shared across the affected languages but scoped to this page to
154+
// avoid reordering valid adjacent conditionals elsewhere.
155+
if (context.relativePath?.endsWith('/securely-using-pull_request_target.md')) {
156+
content = content.replace(
157+
/\{% endif %\}([^{}]*?)\{% ifversion default-pull-req-target-policy %\}/g,
158+
'{% ifversion default-pull-req-target-policy %}$1{% endif %}',
159+
)
160+
}
161+
143162
// --- Per-language fixes (es, ja, pt, zh, ru, fr, ko, de) ---
144163

145164
if (context.code === 'es') {
@@ -340,6 +359,19 @@ export function correctTranslatedContentStrings(
340359
content = content.replace(/^\{%-?\s*elsif\s+/, '{% ifversion ')
341360
}
342361

362+
// get-started/start-your-journey/connecting-to-your-code-locally.md: the
363+
// translator dropped the closing `{% endif %}` after the "Sign in to
364+
// GitHub Enterprise" branch, leaving `{% ifversion fpt or ghec %}` never
365+
// closed (`tag {% ifversion fpt or ghec %} not closed`). English:
366+
// `...click {% ifversion fpt or ghec %}**Sign in to
367+
// {% data variables.product.prodname_dotcom_the_website %}**{% else %}
368+
// **Sign in to {% data variables.product.prodname_enterprise %}**
369+
// {% endif %}.`
370+
content = content.replaceAll(
371+
'{% ifversion fpt or ghec %}{% data variables.product.prodname_dotcom_the_website %}****{% else %}.{% data variables.product.prodname_enterprise %}',
372+
'{% ifversion fpt or ghec %}{% data variables.product.prodname_dotcom_the_website %}****{% else %}{% data variables.product.prodname_enterprise %}{% endif %}.',
373+
)
374+
343375
// enforcing-repository-management-policies-in-your-enterprise.md: the
344376
// second of two near-identical "Under 'Repository...invitations'" steps
345377
// dropped the `{% endif %}` closing the `{% ifversion ghec %}...{% elsif
@@ -725,6 +757,18 @@ export function correctTranslatedContentStrings(
725757
// not found`).
726758
content = content.replace(/\{%(-?)\s*roleColumns\s*=\s*/g, '{%$1 assign roleColumns = ')
727759

760+
// copilot/reference/copilot-feature-matrix.md: the translator reordered
761+
// the inline Liquid tags to match Japanese word order, moving
762+
// `{% endif %}` before the `{% if ideEntry.versionType == "extension" %}`
763+
// that opens the block (repeated 6 times, once per IDE table). English:
764+
// `...across recent versions of the {% if ideEntry.versionType ==
765+
// "extension" %}{% data variables.copilot.copilot_extension %} for the
766+
// {% endif %}IDE.` Swap the tags back into the correct order.
767+
content = content.replaceAll(
768+
'次の表は、{% endif %}IDE の{% if ideEntry.versionType == "extension" %}{% data variables.copilot.copilot_extension %}の',
769+
'次の表は、IDE の{% if ideEntry.versionType == "extension" %}{% data variables.copilot.copilot_extension %}{% endif %}の',
770+
)
771+
728772
// [SCRAPE] data/reusables/actions/github-token-scope-descriptions.md
729773
// (also included by data/reusables/actions/jobs/section-assigning-permissions-to-jobs.md):
730774
// the `{% ifversion vulnerability-alerts-permission %}...{% else %}...{% endif %}`
@@ -1025,6 +1069,18 @@ export function correctTranslatedContentStrings(
10251069
'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 %}.',
10261070
'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 %}.',
10271071
)
1072+
1073+
// copilot/reference/copilot-feature-matrix.md: the translator reordered
1074+
// the inline Liquid tags to match Portuguese word order, moving
1075+
// `{% endif %}` before the `{% if ideEntry.versionType == "extension" %}`
1076+
// that opens the block (repeated 6 times, once per IDE table). English:
1077+
// `...across recent versions of the {% if ideEntry.versionType ==
1078+
// "extension" %}{% data variables.copilot.copilot_extension %} for the
1079+
// {% endif %}IDE.` Swap the tags back into the correct order.
1080+
content = content.replaceAll(
1081+
'do {% endif %}{% if ideEntry.versionType == "extension" %}{% data variables.copilot.copilot_extension %} IDE.',
1082+
'do {% if ideEntry.versionType == "extension" %}{% data variables.copilot.copilot_extension %}{% endif %} IDE.',
1083+
)
10281084
}
10291085

10301086
if (context.code === 'zh') {
@@ -1917,6 +1973,22 @@ export function correctTranslatedContentStrings(
19171973
'{% reusable (fr) classroom.vous-pouvez-créer-une-pull-request-pour-retour %}',
19181974
'{% data reusables.classroom.you-can-create-a-pull-request-for-feedback %}',
19191975
)
1976+
1977+
// data/reusables/repositories/repository-branches.md: the translator
1978+
// reordered the inline Liquid tags to match French word order, moving
1979+
// `{% endif %}` before the `{% elsif ghes %}` branch it should close,
1980+
// leaving `{% ifversion fpt or ghec %}` never closed (`tag
1981+
// {% ifversion fpt or ghec %} not closed`) and orphaning the `»`
1982+
// (closing guillemet) outside the conditional. This reusable is included
1983+
// by managing-a-branch-protection-rule.md and
1984+
// converting-branch-protections-to-rulesets.md. English: `In the
1985+
// {% ifversion fpt or ghec %} "Code, planning, and automation"
1986+
// {% elsif ghes %} "Code and automation"{% endif %} section of the
1987+
// sidebar...`
1988+
content = content.replaceAll(
1989+
'automatisation{% endif %} »{% elsif ghes %} de la barre latérale',
1990+
'automatisation »{% elsif ghes %}{% endif %} de la barre latérale',
1991+
)
19201992
}
19211993

19221994
if (context.code === 'ko') {

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

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3365,4 +3365,70 @@ Para más información, consulta "[AUTOTITLE](/path)".
33653365
expect(fix(fixed, 'ko')).toBe(fixed)
33663366
})
33673367
})
3368+
3369+
describe('securely-using-pull_request_target.md per-file fix', () => {
3370+
const context = {
3371+
relativePath: 'actions/reference/security/securely-using-pull_request_target.md',
3372+
skipOrphanStripping: true,
3373+
}
3374+
3375+
test('swaps a reordered endif/ifversion default-pull-req-target-policy pair back into order', () => {
3376+
const broken =
3377+
'you can opt out of the {% endif %}default event policy and {% ifversion default-pull-req-target-policy %}`actions/checkout` protection.'
3378+
const fixed =
3379+
'you can opt out of the {% ifversion default-pull-req-target-policy %}default event policy and {% endif %}`actions/checkout` protection.'
3380+
for (const code of ['es', 'pt', 'fr', 'ko', 'de']) {
3381+
expect(correctTranslatedContentStrings(broken, '', { ...context, code })).toBe(fixed)
3382+
expect(correctTranslatedContentStrings(fixed, '', { ...context, code })).toBe(fixed)
3383+
}
3384+
})
3385+
3386+
test('does not touch the same feature in other files', () => {
3387+
const untouched =
3388+
'{% ifversion ghec %}foo{% endif %} bar {% ifversion default-pull-req-target-policy %}baz{% endif %}'
3389+
expect(fix(untouched, 'es')).toBe(untouched)
3390+
})
3391+
})
3392+
3393+
describe('connecting-to-your-code-locally.md per-file fix', () => {
3394+
test('es: restores the dropped endif after the Sign in step', () => {
3395+
const broken =
3396+
'{% ifversion fpt or ghec %}{% data variables.product.prodname_dotcom_the_website %}****{% else %}.{% data variables.product.prodname_enterprise %}'
3397+
const fixed =
3398+
'{% ifversion fpt or ghec %}{% data variables.product.prodname_dotcom_the_website %}****{% else %}{% data variables.product.prodname_enterprise %}{% endif %}.'
3399+
expect(fix(broken, 'es')).toBe(fixed)
3400+
expect(fix(fixed, 'es')).toBe(fixed)
3401+
})
3402+
})
3403+
3404+
describe('copilot-feature-matrix.md per-file fix', () => {
3405+
test('ja: swaps the reordered endif/if ideEntry.versionType pair back into order', () => {
3406+
const broken =
3407+
'次の表は、{% endif %}IDE の{% if ideEntry.versionType == "extension" %}{% data variables.copilot.copilot_extension %}の最新バージョンで'
3408+
const fixed =
3409+
'次の表は、IDE の{% if ideEntry.versionType == "extension" %}{% data variables.copilot.copilot_extension %}{% endif %}の最新バージョンで'
3410+
expect(fix(broken, 'ja')).toBe(fixed)
3411+
expect(fix(fixed, 'ja')).toBe(fixed)
3412+
})
3413+
3414+
test('pt: swaps the reordered endif/if ideEntry.versionType pair back into order', () => {
3415+
const broken =
3416+
'suporte em versões recentes do {% endif %}{% if ideEntry.versionType == "extension" %}{% data variables.copilot.copilot_extension %} IDE.'
3417+
const fixed =
3418+
'suporte em versões recentes do {% if ideEntry.versionType == "extension" %}{% data variables.copilot.copilot_extension %}{% endif %} IDE.'
3419+
expect(fix(broken, 'pt')).toBe(fixed)
3420+
expect(fix(fixed, 'pt')).toBe(fixed)
3421+
})
3422+
})
3423+
3424+
describe('data/reusables/repositories/repository-branches.md per-file fix', () => {
3425+
test('fr: moves the misplaced endif after the elsif branch it should close', () => {
3426+
const broken =
3427+
'1. Dans la{% ifversion fpt or ghec %} section « Code, planification et automatisation{% endif %} »{% elsif ghes %} de la barre latérale, cliquez sur **Branches**.'
3428+
const fixed =
3429+
'1. Dans la{% ifversion fpt or ghec %} section « Code, planification et automatisation »{% elsif ghes %}{% endif %} de la barre latérale, cliquez sur **Branches**.'
3430+
expect(fix(broken, 'fr')).toBe(fixed)
3431+
expect(fix(fixed, 'fr')).toBe(fixed)
3432+
})
3433+
})
33683434
})

0 commit comments

Comments
 (0)