Skip to content

Commit 3179338

Browse files
authored
Add translation corrections for es, zh, and ko Liquid tags (#63831)
1 parent 9245795 commit 3179338

2 files changed

Lines changed: 92 additions & 0 deletions

File tree

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ export function correctTranslatedContentStrings(
9494
if (context.code === 'es') {
9595
content = content.replace(/\{%:/g, '{%')
9696

97+
// The translator replaced the space after "data" with a dot, as in {% datos.variables.x %},
98+
// or inserted a stray word, as in {% datos existente variables.x %}.
99+
content = content.replace(
100+
/\{%(-?)\s*datos(?:\.|\s+existente\s+)(variables|reusables)\./g,
101+
'{%$1 data $2.',
102+
)
103+
97104
content = content.replaceAll('{% advertencia %}', '{% warning %}')
98105
content = content.replaceAll('{% siVersion ', '{% ifversion ')
99106
content = content.replaceAll('{%- siVersion ', '{%- ifversion ')
@@ -671,6 +678,9 @@ export function correctTranslatedContentStrings(
671678
}
672679

673680
if (context.code === 'zh') {
681+
// Chinese "变量" ("variables") glued to "data" with no space.
682+
// Also the space-separated form, as in {% data变量 x.y %}, which loses the dot.
683+
content = content.replace(/\{%(-?)\s*data变量(?:\.|\s+)/g, '{%$1 data variables.')
674684
content = content.replaceAll('{% 数据variables', '{% data variables')
675685
content = content.replaceAll('{% 数据 variables', '{% data variables')
676686
content = content.replaceAll('{%数据variables', '{% data variables')
@@ -1247,6 +1257,13 @@ export function correctTranslatedContentStrings(
12471257
}
12481258

12491259
if (context.code === 'ko') {
1260+
// Misspelled "data" keyword and translated IDE/app tag names
1261+
content = content.replaceAll('{% dada variables', '{% data variables')
1262+
content = content.replaceAll('{%- dada variables', '{%- data variables')
1263+
content = content.replaceAll('{% 이클립스 %}', '{% eclipse %}')
1264+
content = content.replaceAll('{%- 이클립스 %}', '{%- eclipse %}')
1265+
content = content.replaceAll('{% 데스크톱 %}', '{% desktop %}')
1266+
content = content.replaceAll('{%- 데스크톱 %}', '{%- desktop %}')
12501267
content = content.replaceAll('{% 경고 %}', '{% warning %}')
12511268
content = content.replaceAll('{% datda variables', '{% data variables')
12521269
content = content.replaceAll('{%- datda variables', '{%- data variables')
@@ -1611,6 +1628,9 @@ export function correctTranslatedContentStrings(
16111628
return match.replace(/[«»“”„]/g, '"').replace(/[‘’‚]/g, "'")
16121629
})
16131630

1631+
// The translator dropped the space between octicon and its quoted name.
1632+
content = content.replace(/\{%(-?)\s*octicon(?=")/g, '{%$1 octicon ')
1633+
16141634
// French « check » becomes " check " after quote normalization.
16151635
content = content.replace(
16161636
/\{%(-?)\s*octicon\s+"\s*([\w-]+)\s*"([^%]*?)(-?)%\}/g,

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

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3405,4 +3405,76 @@ Para más información, consulta "[AUTOTITLE](/path)".
34053405
expect(fix(blank, 'fr')).toBe(blank)
34063406
})
34073407
})
3408+
3409+
describe('data keyword glued to variables or reusables', () => {
3410+
test('es: {% datos.variables. and a stray word between datos and variables', () => {
3411+
expect(fix('{% datos.variables.product.company_short %}', 'es')).toBe(
3412+
'{% data variables.product.company_short %}',
3413+
)
3414+
expect(fix('un {% datos existente variables.copilot.x %} de su', 'es')).toBe(
3415+
'un {% data variables.copilot.x %} de su',
3416+
)
3417+
const ok = '{% data variables.product.company_short %}'
3418+
expect(fix(ok, 'es')).toBe(ok)
3419+
})
3420+
3421+
test('zh: {% data变量. becomes {% data variables.', () => {
3422+
expect(fix('{% data变量.dependabot.github_presets %} 是规则', 'zh')).toBe(
3423+
'{% data variables.dependabot.github_presets %} 是规则',
3424+
)
3425+
const ok = '{% data variables.dependabot.github_presets %}'
3426+
expect(fix(ok, 'zh')).toBe(ok)
3427+
})
3428+
3429+
test('zh: space-separated data变量 restores the dot', () => {
3430+
expect(fix('{% data变量 dependabot.github_presets %} 是规则', 'zh')).toBe(
3431+
'{% data variables.dependabot.github_presets %} 是规则',
3432+
)
3433+
expect(
3434+
fix(
3435+
'{% data变量 dependabot.github_presets %} 是规则',
3436+
'zh',
3437+
'{% data variables.dependabot.github_presets %} are rules',
3438+
),
3439+
).toBe('{% data variables.dependabot.github_presets %} 是规则')
3440+
})
3441+
3442+
test('zh: space-separated data变量 with only whitespace-control data tags', () => {
3443+
expect(
3444+
fix(
3445+
'{%- data变量 dependabot.github_presets %} 是规则',
3446+
'zh',
3447+
'{%- data variables.dependabot.github_presets %} are rules',
3448+
),
3449+
).toBe('{%- data variables.dependabot.github_presets %} 是规则')
3450+
})
3451+
})
3452+
3453+
describe('octicon missing space before quoted name', () => {
3454+
test('restores the space, including after curly-quote normalization', () => {
3455+
expect(fix('{% octicon“kebab-horizontal” aria-label=“图标” %}', 'zh')).toBe(
3456+
'{% octicon "kebab-horizontal" aria-label="图标" %}',
3457+
)
3458+
expect(fix('{% octicon"pulse" aria-hidden="true" %}', 'ja')).toBe(
3459+
'{% octicon "pulse" aria-hidden="true" %}',
3460+
)
3461+
})
3462+
3463+
test('leaves a correct octicon unchanged', () => {
3464+
const ok = '{% octicon "pulse" aria-hidden="true" %}'
3465+
expect(fix(ok, 'ja')).toBe(ok)
3466+
})
3467+
})
3468+
3469+
describe('Korean data keyword and tag names', () => {
3470+
test('fixes {%- dada and translated eclipse and desktop tags', () => {
3471+
expect(fix('{%- dada variables.product.prodname_actions %}', 'ko')).toBe(
3472+
'{%- data variables.product.prodname_actions %}',
3473+
)
3474+
expect(fix('{% 이클립스 %}x{% endeclipse %}', 'ko')).toBe('{% eclipse %}x{% endeclipse %}')
3475+
expect(fix('{%- 데스크톱 %}x{% enddesktop %}', 'ko')).toBe('{%- desktop %}x{% enddesktop %}')
3476+
const ok = '{% data variables.product.prodname_actions %}'
3477+
expect(fix(ok, 'ko')).toBe(ok)
3478+
})
3479+
})
34083480
})

0 commit comments

Comments
 (0)