Skip to content

Commit 9f3d28d

Browse files
docs-botCopilot
andauthored
Add correction patterns for corrupted Liquid in translation repos (#63341)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 06a8f79 commit 9f3d28d

2 files changed

Lines changed: 104 additions & 1 deletion

File tree

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

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ export function correctTranslatedContentStrings(
204204
)
205205
content = content.replaceAll('{{ glosario.term }}', '{{ glossary.term }}')
206206
content = content.replaceAll('{{ glosario.description }}', '{{ glossary.description }}')
207+
// `{{ glosario.descripción }}` — accented Spanish translation of "description"
208+
content = content.replaceAll('{{ glosario.descripción }}', '{{ glossary.description }}')
207209
// Catch "o" and "y/o" between any plan names in ifversion/elsif/if tags
208210
content = content.replace(
209211
/\{%-? (?:ifversion|elsif|if) [^%]*?(?:\by\/o\b|\bo\b)[^%]*?%\}/g,
@@ -267,6 +269,18 @@ export function correctTranslatedContentStrings(
267269
content = content.replaceAll('{% de escritorio %}', '{% desktop %}')
268270
content = content.replaceAll('{%- de escritorio %}', '{%- desktop %}')
269271

272+
// [SCRAPE-6883] data/reusables/apps/generate-installation-access-token.md:
273+
// the `{% endif %}` closing the `{% ifversion enterprise-installed-apps %}`
274+
// block was dropped after the "siempre reciben todos esos permisos"
275+
// sentence, leaving the tag unclosed. This reusable is rendered on
276+
// apps/creating-github-apps/authenticating-with-a-github-app/
277+
// authenticating-as-a-github-app-installation.md and
278+
// generating-an-installation-access-token-for-a-github-app.md too.
279+
content = content.replaceAll(
280+
'Solo tienen acceso a los permisos de empresa que se les han concedido y siempre reciben todos esos permisos.\n',
281+
'Solo tienen acceso a los permisos de empresa que se les han concedido y siempre reciben todos esos permisos.{% endif %}\n',
282+
)
283+
270284
// `{% variablesdatos.producto.` — translator fused "variables" + "datos" (data)
271285
// without the `data` keyword and used "producto" (product) instead of "variables.product".
272286
// e.g. `{% variablesdatos.producto.prodname_dotcom %}` → `{% data variables.product.prodname_dotcom %}`
@@ -301,6 +315,20 @@ export function correctTranslatedContentStrings(
301315
'{% ifversion ghec %}SCIM{% else %} con Okta{% endif %}',
302316
)
303317

318+
// [SCRAPE-6781] codespaces/managing-codespaces-for-your-organization/
319+
// enabling-or-disabling-github-codespaces-for-your-organization.md: the
320+
// translator reordered the inline Liquid tags to match Spanish word
321+
// order, so `{% endif %}` lands before the `{% ifversion ghec %}` that
322+
// opens the block. English source is `...private {% ifversion ghec %}
323+
// and internal {% endif %}repositories`. Reorder the tags around the
324+
// existing translated words so ghec reads "internos y privados" and fpt
325+
// reads "privados". This pattern occurs 3 times in the file (intro plus
326+
// two body paragraphs), all with the identical scrambled substring.
327+
content = content.replaceAll(
328+
'los repositorios internos y {% endif %}privados {% ifversion ghec %}de la organización',
329+
'los repositorios privados {% ifversion ghec %}e internos {% endif %}de la organización',
330+
)
331+
304332
// data/reusables/repositories/you-can-fork.md: translation starts with
305333
// `{% elsif ghes or ghec %}` instead of `{% ifversion ghes or ghec %}` —
306334
// the opening `{% ifversion %}` was replaced with `{% elsif %}`, leaving no
@@ -931,6 +959,18 @@ export function correctTranslatedContentStrings(
931959
// appears as `{% modelo %}` orphaned. Drop unmatched bare `{% modelo %}` is
932960
// risky; instead, leave as-is (Liquid will raise but rare).
933961

962+
// [SCRAPE-6885] apps/creating-github-apps/about-creating-github-apps/
963+
// about-creating-github-apps.md: the translator dropped the closing
964+
// `{% endif %}` (and the word "enterprise,") from the
965+
// `{% ifversion enterprise-installed-apps %}enterprise, {% endif %}`
966+
// fragment, leaving the tag unclosed. English: `...install it on your
967+
// {% ifversion enterprise-installed-apps %}enterprise, {% endif %}
968+
// organization or personal account.`
969+
content = content.replaceAll(
970+
'você precisa instalá-lo em sua conta corporativa, {% ifversion enterprise-installed-apps %}organização ou conta pessoal.',
971+
'você precisa instalá-lo na sua {% ifversion enterprise-installed-apps %}empresa, {% endif %}organização ou conta pessoal.',
972+
)
973+
934974
// Per-file targeted fixes for translator-scrambled Liquid that we can't
935975
// catch via generic patterns. These are scoped tightly to the originating
936976
// file so they're a no-op everywhere else, and they touch only the
@@ -1327,8 +1367,9 @@ export function correctTranslatedContentStrings(
13271367
content = content.replaceAll('{%- конечным %}', '{%- endif %}')
13281368
// `{%- конец %}` — dash-trimmed form of "end" = endif
13291369
content = content.replaceAll('{%- конец %}', '{%- endif %}')
1330-
// `{%- конец для %}` — "end for" = endfor
1370+
// `{%- конец для %}` / `{% конец для %}` — "end for" = endfor
13311371
content = content.replaceAll('{%- конец для %}', '{%- endfor %}')
1372+
content = content.replaceAll('{% конец для %}', '{% endfor %}')
13321373
// `{% заголовки строк %}` — "row headers" = rowheaders (opener; `{% endrowheaders %}` stays in English)
13331374
content = content.replaceAll('{% заголовки строк %}', '{% rowheaders %}')
13341375
content = content.replaceAll('{%- заголовки строк %}', '{%- rowheaders %}')
@@ -2211,6 +2252,21 @@ export function correctTranslatedContentStrings(
22112252
'1. "리포지토리 외부 협력자 초대{% ifversion ghec %}에서 설정 변경에 대한 정보를 검토합니다{% elsif ghes %}." {% data reusables.enterprise-accounts.view-current-policy-config-orgs %}',
22122253
'1. "리포지토리{% ifversion ghec %} 외부 협력자{% elsif ghes %} 초대{% endif %}"에서 설정 변경에 대한 정보를 검토합니다. {% data reusables.enterprise-accounts.view-current-policy-config-orgs %}',
22132254
)
2255+
2256+
// [SCRAPE-6886] data/reusables/package_registry/public-or-private-packages.md:
2257+
// the translator scrambled the `{% ifversion fpt or ghec %}...{% else %}
2258+
// ...{% endif %}` fragment, moving `{% else %}` to the front (with no
2259+
// opener) and leaving the true `{% ifversion %}` opener stranded after
2260+
// the `{% endif %}` it should have preceded (`tag "else" not found`).
2261+
// This reusable is rendered on introduction-to-github-packages.md and
2262+
// publishing-a-package.md too. English: `...to share with
2263+
// {% ifversion fpt or ghec %}all of {% data variables.product.prodname_dotcom %}
2264+
// {% else %}everyone on your enterprise{% endif %}, or in a private
2265+
// repository...`
2266+
content = content.replaceAll(
2267+
'퍼블릭 리포지토리(퍼블릭 패키지)에 패키지를 게시하여 {% else %}엔터프라이즈의 모든 사용자{% endif %}{% ifversion fpt or ghec %} 모두{% data variables.product.prodname_dotcom %}과(와) 공유하거나 프라이빗 리포지토리의 패키지(프라이빗 패키지)를 게시하여 협력자 또는 조직과 공유할 수 있습니다.',
2268+
'퍼블릭 리포지토리(퍼블릭 패키지)에 패키지를 게시하여 {% ifversion fpt or ghec %}모두 {% data variables.product.prodname_dotcom %}과(와){% else %}엔터프라이즈의 모든 사용자와{% endif %} 공유하거나 프라이빗 리포지토리의 패키지(프라이빗 패키지)를 게시하여 협력자 또는 조직과 공유할 수 있습니다.',
2269+
)
22142270
}
22152271

22162272
if (context.code === 'de') {

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ describe('correctTranslatedContentStrings', () => {
103103
expect(fix('{% para glosario en glosarios %}', 'es')).toBe('{% for glossary in glossaries %}')
104104
expect(fix('{{ glosario.term }}', 'es')).toBe('{{ glossary.term }}')
105105
expect(fix('{{ glosario.description }}', 'es')).toBe('{{ glossary.description }}')
106+
expect(fix('{{ glosario.descripción }}', 'es')).toBe('{{ glossary.description }}')
106107
})
107108

108109
test('fixes o and y/o → or in ifversion tags', () => {
@@ -941,6 +942,8 @@ describe('correctTranslatedContentStrings', () => {
941942
expect(fix('{% для глоссария в глоссариях %}', 'ru')).toBe('{% for glossary in glossaries %}')
942943
expect(fix('{{ глоссарий.term }}', 'ru')).toBe('{{ glossary.term }}')
943944
expect(fix('{{ глоссарий.description }}', 'ru')).toBe('{{ glossary.description }}')
945+
expect(fix('{% конец для %}', 'ru')).toBe('{% endfor %}')
946+
expect(fix('{%- конец для %}', 'ru')).toBe('{%- endfor %}')
944947
})
945948

946949
test('fixes rearranged data tag patterns', () => {
@@ -3318,4 +3321,48 @@ Para más información, consulta "[AUTOTITLE](/path)".
33183321
expect(fix(fixed, 'ko')).toBe(fixed)
33193322
})
33203323
})
3324+
3325+
describe('enabling-or-disabling-github-codespaces-for-your-organization.md per-file fix', () => {
3326+
test('es: reorders the scrambled ifversion/endif tags around "privados e internos"', () => {
3327+
const broken =
3328+
'Puede habilitar {% data variables.product.prodname_github_codespaces %} para los repositorios internos y {% endif %}privados {% ifversion ghec %}de la organización.'
3329+
const fixed =
3330+
'Puede habilitar {% data variables.product.prodname_github_codespaces %} para los repositorios privados {% ifversion ghec %}e internos {% endif %}de la organización.'
3331+
expect(fix(broken, 'es')).toBe(fixed)
3332+
expect(fix(fixed, 'es')).toBe(fixed)
3333+
})
3334+
})
3335+
3336+
describe('data/reusables/apps/generate-installation-access-token.md per-file fix', () => {
3337+
test('es: appends the dropped endif after the enterprise scoping sentence', () => {
3338+
const broken =
3339+
'Solo tienen acceso a los permisos de empresa que se les han concedido y siempre reciben todos esos permisos.\nLa respuesta incluirá un token.'
3340+
const fixed =
3341+
'Solo tienen acceso a los permisos de empresa que se les han concedido y siempre reciben todos esos permisos.{% endif %}\nLa respuesta incluirá un token.'
3342+
expect(fix(broken, 'es')).toBe(fixed)
3343+
expect(fix(fixed, 'es')).toBe(fixed)
3344+
})
3345+
})
3346+
3347+
describe('about-creating-github-apps.md per-file fix', () => {
3348+
test('pt: restores the dropped ifversion/endif around "empresa,"', () => {
3349+
const broken =
3350+
'Para usar seu {% data variables.product.prodname_github_app %}, você precisa instalá-lo em sua conta corporativa, {% ifversion enterprise-installed-apps %}organização ou conta pessoal.'
3351+
const fixed =
3352+
'Para usar seu {% data variables.product.prodname_github_app %}, você precisa instalá-lo na sua {% ifversion enterprise-installed-apps %}empresa, {% endif %}organização ou conta pessoal.'
3353+
expect(fix(broken, 'pt')).toBe(fixed)
3354+
expect(fix(fixed, 'pt')).toBe(fixed)
3355+
})
3356+
})
3357+
3358+
describe('data/reusables/package_registry/public-or-private-packages.md per-file fix', () => {
3359+
test('ko: reorders the scrambled ifversion/else/endif fragment', () => {
3360+
const broken =
3361+
'퍼블릭 리포지토리(퍼블릭 패키지)에 패키지를 게시하여 {% else %}엔터프라이즈의 모든 사용자{% endif %}{% ifversion fpt or ghec %} 모두{% data variables.product.prodname_dotcom %}과(와) 공유하거나 프라이빗 리포지토리의 패키지(프라이빗 패키지)를 게시하여 협력자 또는 조직과 공유할 수 있습니다.'
3362+
const fixed =
3363+
'퍼블릭 리포지토리(퍼블릭 패키지)에 패키지를 게시하여 {% ifversion fpt or ghec %}모두 {% data variables.product.prodname_dotcom %}과(와){% else %}엔터프라이즈의 모든 사용자와{% endif %} 공유하거나 프라이빗 리포지토리의 패키지(프라이빗 패키지)를 게시하여 협력자 또는 조직과 공유할 수 있습니다.'
3364+
expect(fix(broken, 'ko')).toBe(fixed)
3365+
expect(fix(fixed, 'ko')).toBe(fixed)
3366+
})
3367+
})
33213368
})

0 commit comments

Comments
 (0)