Skip to content

Commit 136bf20

Browse files
docs-botCopilotheiskr
authored
fix: add new translation corruption patterns to correct-translation-content.ts (#60749)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com>
1 parent 3937b71 commit 136bf20

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,22 @@ export function correctTranslatedContentStrings(
7373
content = content.replace(/\{%-? para (?:la )?entrada en /g, (match) => {
7474
return match.replace(/para (?:la )?entrada en/, 'for entry in')
7575
})
76+
// `{% para el modelo en X %}` — "for the model in" = for model in
77+
content = content.replace(/\{%-? para el modelo en /g, (match) => {
78+
return match.replace('para el modelo en', 'for model in')
79+
})
7680
content = content.replace(/\{%-? cuando /g, (match) => {
7781
return match.replace('cuando', 'when')
7882
})
83+
// `{% icono "X" ... %}` — "icono" = "icon" = octicon
84+
content = content.replaceAll('{% icono ', '{% octicon ')
85+
content = content.replaceAll('{%- icono ', '{%- octicon ')
86+
// `{% octicon "bombilla" %}` — Spanish "bombilla" = "light-bulb" (translated octicon name)
87+
content = content.replaceAll('{% octicon "bombilla"', '{% octicon "light-bulb"')
88+
content = content.replaceAll('{%- octicon "bombilla"', '{%- octicon "light-bulb"')
89+
// `{% capturar X %}` — "capturar" = "to capture" = capture
90+
content = content.replaceAll('{% capturar ', '{% capture ')
91+
content = content.replaceAll('{%- capturar ', '{%- capture ')
7992
// Translated block tags
8093
content = content.replaceAll('{% nota %}', '{% note %}')
8194
content = content.replaceAll('{%- nota %}', '{%- note %}')
@@ -216,6 +229,9 @@ export function correctTranslatedContentStrings(
216229
// `{% ウィンドウズ %}` — "Windows" = windows (platform tag)
217230
content = content.replaceAll('{% ウィンドウズ %}', '{% windows %}')
218231
content = content.replaceAll('{%- ウィンドウズ %}', '{%- windows %}')
232+
// `{% ウィンドウ %}` — "Window" (without ズ suffix) = windows (alternate transliteration)
233+
content = content.replaceAll('{% ウィンドウ %}', '{% windows %}')
234+
content = content.replaceAll('{%- ウィンドウ %}', '{%- windows %}')
219235
}
220236

221237
if (context.code === 'pt') {
@@ -403,6 +419,9 @@ export function correctTranslatedContentStrings(
403419
// `{% Linux %}` — capitalized linux platform tag
404420
content = content.replaceAll('{% Linux %}', '{% linux %}')
405421
content = content.replaceAll('{%- Linux %}', '{%- linux %}')
422+
// `{% джетмозги %}` — Russian literal translation of "JetBrains" (джет=jet, мозги=brains)
423+
content = content.replaceAll('{% джетмозги %}', '{% jetbrains %}')
424+
content = content.replaceAll('{%- джетмозги %}', '{%- jetbrains %}')
406425
// Fix double quotes in Russian YAML files that cause parsing errors
407426
content = content.replace(/href=""https:\/\//g, 'href="https://')
408427

@@ -493,6 +512,27 @@ export function correctTranslatedContentStrings(
493512
// `{% éclipse %}` — French accent on "eclipse" platform tag
494513
content = content.replaceAll('{% éclipse %}', '{% eclipse %}')
495514
content = content.replaceAll('{%- éclipse %}', '{%- eclipse %}')
515+
// `{% données_reutilisables.X %}` — underscore form of "données réutilisables" (no accent)
516+
content = content.replaceAll('{% données_reutilisables.', '{% data reusables.')
517+
content = content.replaceAll('{%- données_reutilisables.', '{%- data reusables.')
518+
// `{% données_réutilisables.X %}` — underscore form with accent
519+
content = content.replaceAll('{% données_réutilisables.', '{% data reusables.')
520+
content = content.replaceAll('{%- données_réutilisables.', '{%- data reusables.')
521+
// `{% composants réutilisables.X %}` — "composants" = "components" as alias for data reusables
522+
content = content.replaceAll('{% composants réutilisables.', '{% data reusables.')
523+
content = content.replaceAll('{%- composants réutilisables.', '{%- data reusables.')
524+
// Fully-translated `{% données réutilisables propriétés-personnalisées valeurs-requises %}`
525+
// → `{% data reusables.organizations.custom-properties-required-values %}`
526+
// Note: the generic `{% données ` → `{% data ` fix above may already have transformed
527+
// `données` to `data`, so we match both the original and the partially-corrected form.
528+
content = content.replaceAll(
529+
'{% données réutilisables propriétés-personnalisées valeurs-requises %}',
530+
'{% data reusables.organizations.custom-properties-required-values %}',
531+
)
532+
content = content.replaceAll(
533+
'{% data réutilisables propriétés-personnalisées valeurs-requises %}',
534+
'{% data reusables.organizations.custom-properties-required-values %}',
535+
)
496536
// Remove orphaned {% endif %} tags when no ifversion/elsif opener exists in the content.
497537
// Caused by translations where only the closing tag survived (e.g. user-api.md reusable).
498538
if (
@@ -542,6 +582,12 @@ export function correctTranslatedContentStrings(
542582
// `{% 윈도우즈 %}` — Korean transliteration of "windows"
543583
content = content.replaceAll('{% 윈도우즈 %}', '{% windows %}')
544584
content = content.replaceAll('{%- 윈도우즈 %}', '{%- windows %}')
585+
// `{% 엔드맥 %}` — Korean translation of "endmac" (end + mac)
586+
content = content.replaceAll('{% 엔드맥 %}', '{% endmac %}')
587+
content = content.replaceAll('{%- 엔드맥 %}', '{%- endmac %}')
588+
// `{% 주석 끝 %}` — Korean "주석 끝" (note end) = endnote
589+
content = content.replaceAll('{% 주석 끝 %}', '{% endnote %}')
590+
content = content.replaceAll('{%- 주석 끝 %}', '{%- endnote %}')
545591
}
546592

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

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

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,34 @@ describe('correctTranslatedContentStrings', () => {
9191
expect(fix('{%- encabezados de fila %}', 'es')).toBe('{%- rowheaders %}')
9292
})
9393

94+
test('fixes icono → octicon', () => {
95+
expect(fix('{% icono "copilot" aria-hidden="true" aria-label="Copilot" %}', 'es')).toBe(
96+
'{% octicon "copilot" aria-hidden="true" aria-label="Copilot" %}',
97+
)
98+
expect(fix('{%- icono "check" %}', 'es')).toBe('{%- octicon "check" %}')
99+
})
100+
101+
test('fixes octicon "bombilla" → octicon "light-bulb"', () => {
102+
expect(fix('{% octicon "bombilla" aria-label="The light-bulb icon" %}', 'es')).toBe(
103+
'{% octicon "light-bulb" aria-label="The light-bulb icon" %}',
104+
)
105+
expect(fix('{%- octicon "bombilla" aria-label="The light-bulb icon" %}', 'es')).toBe(
106+
'{%- octicon "light-bulb" aria-label="The light-bulb icon" %}',
107+
)
108+
})
109+
110+
test('fixes capturar → capture', () => {
111+
expect(fix('{% capturar service_name %}runner{% endcapture %}', 'es')).toBe(
112+
'{% capture service_name %}runner{% endcapture %}',
113+
)
114+
})
115+
116+
test('fixes para el modelo en → for model in', () => {
117+
expect(fix('{% para el modelo en tables.copilot.model-comparison %}', 'es')).toBe(
118+
'{% for model in tables.copilot.model-comparison %}',
119+
)
120+
})
121+
94122
test('fixes multiple or-translations in single ifversion', () => {
95123
expect(fix('{% ifversion fpt o ghec o ghes %}', 'es')).toBe(
96124
'{% ifversion fpt or ghec or ghes %}',
@@ -262,6 +290,11 @@ describe('correctTranslatedContentStrings', () => {
262290
expect(fix('{% ウィンドウズ %}', 'ja')).toBe('{% windows %}')
263291
expect(fix('{%- ウィンドウズ %}', 'ja')).toBe('{%- windows %}')
264292
})
293+
294+
test('fixes ウィンドウ (without ズ) → windows', () => {
295+
expect(fix('{% ウィンドウ %}', 'ja')).toBe('{% windows %}')
296+
expect(fix('{%- ウィンドウ %}', 'ja')).toBe('{%- windows %}')
297+
})
265298
})
266299

267300
// ─── PORTUGUESE (pt) ───────────────────────────────────────────────
@@ -616,6 +649,11 @@ describe('correctTranslatedContentStrings', () => {
616649
expect(fix('{% Linux %}', 'ru')).toBe('{% linux %}')
617650
expect(fix('{%- Linux %}', 'ru')).toBe('{%- linux %}')
618651
})
652+
653+
test('fixes джетмозги → jetbrains', () => {
654+
expect(fix('{% джетмозги %}', 'ru')).toBe('{% jetbrains %}')
655+
expect(fix('{%- джетмозги %}', 'ru')).toBe('{%- jetbrains %}')
656+
})
619657
})
620658

621659
// ─── FRENCH (fr) ───────────────────────────────────────────────────
@@ -712,6 +750,27 @@ describe('correctTranslatedContentStrings', () => {
712750
expect(fix('{% éclipse %}', 'fr')).toBe('{% eclipse %}')
713751
expect(fix('{%- éclipse %}', 'fr')).toBe('{%- eclipse %}')
714752
})
753+
754+
test('fixes données_reutilisables → data reusables', () => {
755+
expect(fix('{% données_reutilisables.user-settings.ssh %}', 'fr')).toBe(
756+
'{% data reusables.user-settings.ssh %}',
757+
)
758+
expect(fix('{% données_réutilisables.codespaces.foo %}', 'fr')).toBe(
759+
'{% data reusables.codespaces.foo %}',
760+
)
761+
})
762+
763+
test('fixes composants réutilisables → data reusables', () => {
764+
expect(fix('{% composants réutilisables.répertoires.barre-latérale-sujets %}', 'fr')).toBe(
765+
'{% data reusables.répertoires.barre-latérale-sujets %}',
766+
)
767+
})
768+
769+
test('fixes fully-translated données réutilisables propriétés-personnalisées path', () => {
770+
expect(
771+
fix('{% données réutilisables propriétés-personnalisées valeurs-requises %}', 'fr'),
772+
).toBe('{% data reusables.organizations.custom-properties-required-values %}')
773+
})
715774
})
716775

717776
// ─── KOREAN (ko) ──────────────────────────────────────────────────
@@ -790,6 +849,16 @@ describe('correctTranslatedContentStrings', () => {
790849
expect(fix('{% 윈도우즈 %}', 'ko')).toBe('{% windows %}')
791850
expect(fix('{%- 윈도우즈 %}', 'ko')).toBe('{%- windows %}')
792851
})
852+
853+
test('fixes 엔드맥 → endmac', () => {
854+
expect(fix('{% 엔드맥 %}', 'ko')).toBe('{% endmac %}')
855+
expect(fix('{%- 엔드맥 %}', 'ko')).toBe('{%- endmac %}')
856+
})
857+
858+
test('fixes 주석 끝 → endnote', () => {
859+
expect(fix('{% 주석 끝 %}', 'ko')).toBe('{% endnote %}')
860+
expect(fix('{%- 주석 끝 %}', 'ko')).toBe('{%- endnote %}')
861+
})
793862
})
794863

795864
// ─── GERMAN (de) ──────────────────────────────────────────────────

0 commit comments

Comments
 (0)