Skip to content

Commit 6c3a65a

Browse files
docs-botCopilot
andauthored
Fix translated ifversion flag names causing hidden content in ja/zh/ko/de/pt (#62860)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent cf960fc commit 6c3a65a

2 files changed

Lines changed: 124 additions & 0 deletions

File tree

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

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,16 @@ export function correctTranslatedContentStrings(
463463
// `{% indented_data_reference 再利用可能.X.Y spaces=N %}` — translated path
464464
content = content.replace(/(\{%-?\s*indented_data_reference\s+)\./g, '$1reusables.')
465465

466+
// `{% ifversion コマンド パレット %}` — translated flag name "command palette" = command-palette
467+
content = content.replaceAll(
468+
'{% ifversion コマンド パレット %}',
469+
'{% ifversion command-palette %}',
470+
)
471+
content = content.replaceAll(
472+
'{%- ifversion コマンド パレット %}',
473+
'{%- ifversion command-palette %}',
474+
)
475+
466476
// [SCRAPE-6548] Per-file fixes for ja pages whose intro/title/shortTitle
467477
// Liquid was structurally scrambled (orphan endif, swapped tag order,
468478
// unclosed ifversion). Each replacement is scoped by the unique broken
@@ -649,6 +659,10 @@ export function correctTranslatedContentStrings(
649659
content = content.replace(/\{%-? (?:ifversion|elsif|if) [^%]*?ou [^%]*?%\}/g, (match) => {
650660
return match.replace(/ ou /g, ' or ')
651661
})
662+
// Portuguese "não" for "not" in ifversion/elsif/if tags (e.g. `{% ifversion não ghes %}`)
663+
content = content.replace(/\{%-? (?:ifversion|elsif|if) [^%]*?\bnão\b[^%]*?%\}/g, (match) => {
664+
return match.replace(/\bnão\b/g, 'not')
665+
})
652666
// Fully translated reusable path in audit log article:
653667
// `{% dados agrupados por categoria.complemento.audit_log.reference-grouped-by-category %}`
654668
content = content.replaceAll(
@@ -838,6 +852,16 @@ export function correctTranslatedContentStrings(
838852
content = content.replaceAll('{%- 行标头 %}', '{%- rowheaders %}')
839853
content = content.replaceAll('{% 行标题 %}', '{% rowheaders %}')
840854
content = content.replaceAll('{%- 行标题 %}', '{%- rowheaders %}')
855+
856+
// `{% ifversion 命令面板 %}` — translated flag name "command panel" = command-palette
857+
content = content.replaceAll('{% ifversion 命令面板 %}', '{% ifversion command-palette %}')
858+
content = content.replaceAll('{%- ifversion 命令面板 %}', '{%- ifversion command-palette %}')
859+
// `{% ifversion 子问题 %}` — translated flag name "sub-issues" (子问题)
860+
content = content.replaceAll('{% ifversion 子问题 %}', '{% ifversion sub-issues %}')
861+
content = content.replaceAll('{%- ifversion 子问题 %}', '{%- ifversion sub-issues %}')
862+
// `{% ifversion 问题类型 %}` — translated flag name "issue types" = issue-types
863+
content = content.replaceAll('{% ifversion 问题类型 %}', '{% ifversion issue-types %}')
864+
content = content.replaceAll('{%- ifversion 问题类型 %}', '{%- ifversion issue-types %}')
841865
// `{% 结束行标题 %}` / `{% 结束行标头 %}` / `{% 结束行头 %}` — endrowheaders
842866
content = content.replaceAll('{% 结束行标题 %}', '{% endrowheaders %}')
843867
content = content.replaceAll('{%- 结束行标题 %}', '{%- endrowheaders %}')
@@ -1636,6 +1660,31 @@ export function correctTranslatedContentStrings(
16361660
content = content.replaceAll('{% 옥티콘 ', '{% octicon ')
16371661
content = content.replaceAll('{%- 옥티콘 ', '{%- octicon ')
16381662

1663+
// `{% ifversion 명령 팔레트 %}` — translated flag name "command palette" = command-palette
1664+
content = content.replaceAll('{% ifversion 명령 팔레트 %}', '{% ifversion command-palette %}')
1665+
content = content.replaceAll('{%- ifversion 명령 팔레트 %}', '{%- ifversion command-palette %}')
1666+
// `{% ifversion 하위 문제 %}` — translated flag name "sub-issues" (하위 문제)
1667+
content = content.replaceAll('{% ifversion 하위 문제 %}', '{% ifversion sub-issues %}')
1668+
content = content.replaceAll('{%- ifversion 하위 문제 %}', '{%- ifversion sub-issues %}')
1669+
// `{% ifversion 리포지토리-규칙 관리 %}` — translated flag name "repository-rules management"
1670+
content = content.replaceAll(
1671+
'{% ifversion 리포지토리-규칙 관리 %}',
1672+
'{% ifversion repo-rules-management %}',
1673+
)
1674+
content = content.replaceAll(
1675+
'{%- ifversion 리포지토리-규칙 관리 %}',
1676+
'{%- ifversion repo-rules-management %}',
1677+
)
1678+
// `{% ifversion 업데이트 알림 설정-22 %}` — translated flag name "update notification settings-22"
1679+
content = content.replaceAll(
1680+
'{% ifversion 업데이트 알림 설정-22 %}',
1681+
'{% ifversion update-notification-settings-22 %}',
1682+
)
1683+
content = content.replaceAll(
1684+
'{%- ifversion 업데이트 알림 설정-22 %}',
1685+
'{%- ifversion update-notification-settings-22 %}',
1686+
)
1687+
16391688
// `{% data Variables.` — capital V in "Variables" (Korean translator capitalised the word)
16401689
content = content.replaceAll('{% data Variables.', '{% data variables.')
16411690
content = content.replaceAll('{%- data Variables.', '{%- data variables.')
@@ -1936,6 +1985,16 @@ export function correctTranslatedContentStrings(
19361985
// Translated tag name `{% eingerucktes_datenverweis ... %}` → `{% indented_data_reference ... %}`
19371986
content = content.replaceAll('{% eingerucktes_datenverweis ', '{% indented_data_reference ')
19381987
content = content.replaceAll('{%- eingerucktes_datenverweis ', '{%- indented_data_reference ')
1988+
// `{% ifversion unveränderliche Versionen %}` — translated flag name
1989+
// "immutable releases" = immutable-releases
1990+
content = content.replaceAll(
1991+
'{% ifversion unveränderliche Versionen %}',
1992+
'{% ifversion immutable-releases %}',
1993+
)
1994+
content = content.replaceAll(
1995+
'{%- ifversion unveränderliche Versionen %}',
1996+
'{%- ifversion immutable-releases %}',
1997+
)
19391998

19401999
// [SCRAPE-6548] Per-file fix:
19412000
// organizations/.../permissions-of-custom-organization-roles.md (intro):

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

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,14 @@ describe('correctTranslatedContentStrings', () => {
222222
expect(fix('{%- ifversion fpt または ghec %}', 'ja')).toBe('{%- ifversion fpt or ghec %}')
223223
})
224224

225+
test('fixes translated command-palette flag name', () => {
226+
expect(fix('{% ifversion コマンド パレット %}', 'ja')).toBe('{% ifversion command-palette %}')
227+
expect(fix('{%- ifversion コマンド パレット %}', 'ja')).toBe(
228+
'{%- ifversion command-palette %}',
229+
)
230+
expect(fix('{% ifversion command-palette %}', 'ja')).toBe('{% ifversion command-palette %}')
231+
})
232+
225233
test('fixes trailing quote on YAML value', () => {
226234
expect(fix(' asked_too_many_times: some value" ', 'ja')).toBe(
227235
' asked_too_many_times: some value',
@@ -404,6 +412,12 @@ describe('correctTranslatedContentStrings', () => {
404412
expect(fix('{%– endif %}', 'pt')).toBe('{%- endif %}')
405413
})
406414

415+
test('fixes Portuguese não (not) in ifversion tags', () => {
416+
expect(fix('{% ifversion não ghes %}', 'pt')).toBe('{% ifversion not ghes %}')
417+
expect(fix('{%- ifversion não ghes %}', 'pt')).toBe('{%- ifversion not ghes %}')
418+
expect(fix('{% ifversion not ghes %}', 'pt')).toBe('{% ifversion not ghes %}')
419+
})
420+
407421
test('fixes datavariables / dadosvariables (no space)', () => {
408422
// `{% datavariables` — no space between "data" and "variables" (post-translation)
409423
expect(fix('{% datavariables.product.github %}', 'pt')).toBe(
@@ -562,6 +576,18 @@ describe('correctTranslatedContentStrings', () => {
562576
expect(fix('{ 如果 ghec %}', 'zh')).toBe('{% if ghec %}')
563577
})
564578

579+
test('fixes translated flag names in ifversion tags', () => {
580+
expect(fix('{% ifversion 命令面板 %}', 'zh')).toBe('{% ifversion command-palette %}')
581+
expect(fix('{%- ifversion 命令面板 %}', 'zh')).toBe('{%- ifversion command-palette %}')
582+
expect(fix('{% ifversion 子问题 %}', 'zh')).toBe('{% ifversion sub-issues %}')
583+
expect(fix('{%- ifversion 子问题 %}', 'zh')).toBe('{%- ifversion sub-issues %}')
584+
expect(fix('{% ifversion 问题类型 %}', 'zh')).toBe('{% ifversion issue-types %}')
585+
expect(fix('{%- ifversion 问题类型 %}', 'zh')).toBe('{%- ifversion issue-types %}')
586+
expect(fix('{% ifversion command-palette %}', 'zh')).toBe('{% ifversion command-palette %}')
587+
expect(fix('{% ifversion sub-issues %}', 'zh')).toBe('{% ifversion sub-issues %}')
588+
expect(fix('{% ifversion issue-types %}', 'zh')).toBe('{% ifversion issue-types %}')
589+
})
590+
565591
test('fixes stray Chinese then merged with HTML', () => {
566592
expect(fix(',则为 {%<div>', 'zh')).toBe('<div>')
567593
})
@@ -1172,6 +1198,33 @@ describe('correctTranslatedContentStrings', () => {
11721198
)
11731199
})
11741200

1201+
test('fixes translated flag names in ifversion tags', () => {
1202+
expect(fix('{% ifversion 명령 팔레트 %}', 'ko')).toBe('{% ifversion command-palette %}')
1203+
expect(fix('{%- ifversion 명령 팔레트 %}', 'ko')).toBe('{%- ifversion command-palette %}')
1204+
expect(fix('{% ifversion 하위 문제 %}', 'ko')).toBe('{% ifversion sub-issues %}')
1205+
expect(fix('{%- ifversion 하위 문제 %}', 'ko')).toBe('{%- ifversion sub-issues %}')
1206+
expect(fix('{% ifversion 리포지토리-규칙 관리 %}', 'ko')).toBe(
1207+
'{% ifversion repo-rules-management %}',
1208+
)
1209+
expect(fix('{%- ifversion 리포지토리-규칙 관리 %}', 'ko')).toBe(
1210+
'{%- ifversion repo-rules-management %}',
1211+
)
1212+
expect(fix('{% ifversion 업데이트 알림 설정-22 %}', 'ko')).toBe(
1213+
'{% ifversion update-notification-settings-22 %}',
1214+
)
1215+
expect(fix('{%- ifversion 업데이트 알림 설정-22 %}', 'ko')).toBe(
1216+
'{%- ifversion update-notification-settings-22 %}',
1217+
)
1218+
expect(fix('{% ifversion command-palette %}', 'ko')).toBe('{% ifversion command-palette %}')
1219+
expect(fix('{% ifversion sub-issues %}', 'ko')).toBe('{% ifversion sub-issues %}')
1220+
expect(fix('{% ifversion repo-rules-management %}', 'ko')).toBe(
1221+
'{% ifversion repo-rules-management %}',
1222+
)
1223+
expect(fix('{% ifversion update-notification-settings-22 %}', 'ko')).toBe(
1224+
'{% ifversion update-notification-settings-22 %}',
1225+
)
1226+
})
1227+
11751228
test('fixes dada → data (via generic)', () => {
11761229
expect(fix('{% dada variables.product.github %}', 'ko')).toBe(
11771230
'{% data variables.product.github %}',
@@ -1291,6 +1344,18 @@ describe('correctTranslatedContentStrings', () => {
12911344
expect(fix('{% ifversion fpt oder ghec %}', 'de')).toBe('{% ifversion fpt or ghec %}')
12921345
})
12931346

1347+
test('fixes translated immutable-releases flag name', () => {
1348+
expect(fix('{% ifversion unveränderliche Versionen %}', 'de')).toBe(
1349+
'{% ifversion immutable-releases %}',
1350+
)
1351+
expect(fix('{%- ifversion unveränderliche Versionen %}', 'de')).toBe(
1352+
'{%- ifversion immutable-releases %}',
1353+
)
1354+
expect(fix('{% ifversion immutable-releases %}', 'de')).toBe(
1355+
'{% ifversion immutable-releases %}',
1356+
)
1357+
})
1358+
12941359
test('fixes translated block tags', () => {
12951360
expect(fix('{% Hinweis %}', 'de')).toBe('{% note %}')
12961361
expect(fix('{%- Hinweis %}', 'de')).toBe('{%- note %}')

0 commit comments

Comments
 (0)