Skip to content

Commit da0fec8

Browse files
committed
fix(parse-locale.js in deepl): translation is not working for traditional chinese locales(zh-Hant)
always translating to simplified chinese locale eventhough i am trying to do for a traditional locale.
1 parent 0850fd0 commit da0fec8

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,4 @@ build/
136136

137137
**/cypress/videos
138138
**/cypress/screenshots
139+
.idea

providers/deepl/lib/__tests__/parse-locale.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,18 @@ describe('locale parser', () => {
7474
it('source language is parsed without specific locale even with locale map', () => {
7575
expect(parseLocale('en-GB', {}, 'source')).toEqual('EN')
7676
})
77+
it('source language is parsed without specific locale for zh-Hant-tw', () => {
78+
const localeMap = {
79+
'ZH-HANT-TW': 'ZH-HANT',
80+
'ZH-HANT': 'ZH-HANT',
81+
};
82+
expect(parseLocale('zh-Hant-tw', localeMap)).toEqual('ZH-HANT');
83+
})
84+
it('source language is parsed without specific locale for zh-Hant', () => {
85+
const localeMap = {
86+
'ZH-HANT-TW': 'ZH-HANT',
87+
'ZH-HANT': 'ZH-HANT',
88+
};
89+
expect(parseLocale('zh-Hant', localeMap)).toEqual('ZH-HANT');
90+
})
7791
})

providers/deepl/lib/parse-locale.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function parseLocale(strapiLocale, localeMap = {}, direction = 'target') {
5555
case 'TR':
5656
case 'UK':
5757
case 'ZH':
58-
possiblyUnstrippedResult = localeMap[stripped] || stripped
58+
possiblyUnstrippedResult = localeMap[unstripped] || localeMap[stripped] || stripped
5959
break
6060
case 'PT':
6161
if (unstripped == 'PT-PT') possiblyUnstrippedResult = unstripped

0 commit comments

Comments
 (0)