Skip to content

Commit 23cb10e

Browse files
docs-botCopilotCopilotheiskr
authored
fix: add new translation corruption patterns for fr, ru, ko, de (#61167)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: heiskr <1221423+heiskr@users.noreply.github.com> Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com>
1 parent 7ba62a3 commit 23cb10e

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,17 @@ export function correctTranslatedContentStrings(
809809
// `{% заголовки строк %}` — "row headers" = rowheaders (opener; `{% endrowheaders %}` stays in English)
810810
content = content.replaceAll('{% заголовки строк %}', '{% rowheaders %}')
811811
content = content.replaceAll('{%- заголовки строк %}', '{%- rowheaders %}')
812+
// `{% windowsTerminal %}` — "Windows Terminal" platform tag with capital T
813+
// (the correct tag name is lowercase `{% windowsterminal %}`)
814+
content = content.replaceAll('{% windowsTerminal %}', '{% windowsterminal %}')
815+
content = content.replaceAll('{%- windowsTerminal %}', '{%- windowsterminal %}')
816+
// `{%- командная палитра ifversion %}` — "command palette ifversion" with word order swapped
817+
// Russian "командная палитра" (command palette) was placed before "ifversion" and the
818+
// feature-flag arg was dropped. Recover as `{%- ifversion command-palette %}`.
819+
content = content.replace(
820+
/\{%(-?)\s*командная\s+палитра\s+ifversion\s*(-?)%\}/g,
821+
'{%$1 ifversion command-palette $2%}',
822+
)
812823
// `{% конец %}` after `{% raw %}` means `{% endraw %}`, not `{% endif %}`.
813824
// Handle this BEFORE the generic `{% конец %}` → `{% endif %}` fallback.
814825
// We use a split-based approach instead of `[^]*?` regex to avoid
@@ -1030,6 +1041,11 @@ export function correctTranslatedContentStrings(
10301041
content = content.replace(/\{%-?\s*référentiel\s*-?%\}/g, '')
10311042
content = content.replace(/\{%-?\s*paramètres\s*-?%\}/g, '')
10321043
content = content.replace(/\{%-?\s*product\s*-?%\}/g, '')
1044+
// `{% données.variables.X %}` — translator used `.` instead of space after "données"
1045+
content = content.replace(
1046+
/\{%(-?)\s*données\.(variables|reusables)\.([A-Za-z0-9._-]+)(\s*-?%\})/g,
1047+
'{%$1 data $2.$3$4',
1048+
)
10331049
content = content.replaceAll('{% données variables', '{% data variables')
10341050
content = content.replaceAll('{% données réutilisables.', '{% data reusables.')
10351051
content = content.replaceAll('{% variables de données.', '{% data variables.')
@@ -1174,6 +1190,17 @@ export function correctTranslatedContentStrings(
11741190
}
11751191

11761192
if (context.code === 'ko') {
1193+
// `{% datda variables.` — typo of "data" (d-a-t-d-a instead of d-a-t-a)
1194+
content = content.replaceAll('{% datda variables', '{% data variables')
1195+
content = content.replaceAll('{%- datda variables', '{%- data variables')
1196+
// `{% data를 [Korean] variables.X %}` — Korean object-marker "를" (object case particle)
1197+
// was accidentally appended to "data", and Korean words follow before the path.
1198+
// e.g. `{% data를 탐색하고 수락하기 variables.copilot.next_edit_suggestions %}`
1199+
// Strip the Korean text and restore the correct `{% data variables.X %}` tag.
1200+
content = content.replace(
1201+
/\{%(-?)\s*data\s+[-\s]+variables\.([A-Za-z0-9._-]+)\s*(-?)%\}/g,
1202+
'{%$1 data variables.$2 $3%}',
1203+
)
11771204
content = content.replaceAll('[AUTOTITLE"을 참조하세요]', '[AUTOTITLE]')
11781205
content = content.replaceAll('{% 데이터 variables', '{% data variables')
11791206
content = content.replaceAll('{% 데이터 reusables.', '{% data reusables.')
@@ -1300,6 +1327,9 @@ export function correctTranslatedContentStrings(
13001327
content = content.replaceAll('{% daten variables', '{% data variables')
13011328
content = content.replaceAll('{% Daten reusables', '{% data reusables')
13021329
content = content.replaceAll('{%- Daten reusables', '{%- data reusables')
1330+
// `{% Datenseite variables.` — "Datenseite" (data page) compound used instead of "data"
1331+
content = content.replaceAll('{% Datenseite variables', '{% data variables')
1332+
content = content.replaceAll('{%- Datenseite variables', '{%- data variables')
13031333
// `wiederverwendbare` is German for "reusables" — fix translated reusables paths
13041334
content = content.replaceAll('{% data wiederverwendbare.', '{% data reusables.')
13051335
content = content.replaceAll('{% Daten wiederverwendbare.', '{% data reusables.')

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,21 @@ describe('correctTranslatedContentStrings', () => {
662662
expect(fix('{%- заголовки строк %}', 'ru')).toBe('{%- rowheaders %}')
663663
})
664664

665+
test('fixes windowsTerminal → windowsterminal', () => {
666+
expect(fix('{% windowsTerminal %}', 'ru')).toBe('{% windowsterminal %}')
667+
expect(fix('{%- windowsTerminal %}', 'ru')).toBe('{%- windowsterminal %}')
668+
})
669+
670+
test('fixes командная палитра ifversion → ifversion command-palette', () => {
671+
expect(fix('{%- командная палитра ifversion %}', 'ru')).toBe(
672+
'{%- ifversion command-palette %}',
673+
)
674+
expect(fix('{% командная палитра ifversion %}', 'ru')).toBe('{% ifversion command-palette %}')
675+
expect(fix('{%- командная палитра ifversion -%}', 'ru')).toBe(
676+
'{%- ifversion command-palette -%}',
677+
)
678+
})
679+
665680
test('fixes translated feature flag names', () => {
666681
expect(fix('обязательный-2fa-dotcom-участник', 'ru')).toBe(
667682
'mandatory-2fa-dotcom-contributors',
@@ -765,6 +780,11 @@ describe('correctTranslatedContentStrings', () => {
765780
expect(fix('{% de data variables.product.github %}', 'fr')).toBe(
766781
'{% data variables.product.github %}',
767782
)
783+
// `{% données.variables.X %}` — dot instead of space after "données"
784+
expect(fix('{% données.variables.copilot.copilot_chat_short %}', 'fr')).toBe(
785+
'{% data variables.copilot.copilot_chat_short %}',
786+
)
787+
expect(fix('{% données.reusables.foo.bar %}', 'fr')).toBe('{% data reusables.foo.bar %}')
768788
})
769789

770790
test('fixes translated else', () => {
@@ -882,6 +902,24 @@ describe('correctTranslatedContentStrings', () => {
882902
expect(fix('[AUTOTITLE"을 참조하세요]', 'ko')).toBe('[AUTOTITLE]')
883903
})
884904

905+
test('fixes datda → data typo', () => {
906+
expect(fix('{% datda variables.product.github %}', 'ko')).toBe(
907+
'{% data variables.product.github %}',
908+
)
909+
expect(fix('{%- datda variables.copilot.foo %}', 'ko')).toBe(
910+
'{%- data variables.copilot.foo %}',
911+
)
912+
})
913+
914+
test('fixes data를 Korean-particle corruption', () => {
915+
expect(
916+
fix('{% data를 탐색하고 수락하기 variables.copilot.next_edit_suggestions %}', 'ko'),
917+
).toBe('{% data variables.copilot.next_edit_suggestions %}')
918+
expect(
919+
fix('{%- data를 탐색하고 수락하기 variables.copilot.next_edit_suggestions -%}', 'ko'),
920+
).toBe('{%- data variables.copilot.next_edit_suggestions -%}')
921+
})
922+
885923
test('fixes translated data tags', () => {
886924
expect(fix('{% 데이터 variables.product.github %}', 'ko')).toBe(
887925
'{% data variables.product.github %}',
@@ -992,6 +1030,13 @@ describe('correctTranslatedContentStrings', () => {
9921030
)
9931031
expect(fix('{% Daten reusables.foo %}', 'de')).toBe('{% data reusables.foo %}')
9941032
expect(fix('{%- Daten reusables.foo %}', 'de')).toBe('{%- data reusables.foo %}')
1033+
// `{% Datenseite variables.` — "Datenseite" (data page) compound = data
1034+
expect(fix('{% Datenseite variables.product.prodname_github_app %}', 'de')).toBe(
1035+
'{% data variables.product.prodname_github_app %}',
1036+
)
1037+
expect(fix('{%- Datenseite variables.product.foo %}', 'de')).toBe(
1038+
'{%- data variables.product.foo %}',
1039+
)
9951040
})
9961041

9971042
test('fixes hyphenated data tags without space', () => {

0 commit comments

Comments
 (0)