Skip to content

Commit 768ca9e

Browse files
authored
Merge pull request #62 from Yohannfra/main
fix: add missing types for zh-HANS and zh-HANT (fix #58)
2 parents 888adb0 + c61ec5a commit 768ca9e

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

Diff for: src/types.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,14 @@ export type SourceLanguageCode = CommonLanguageCode | 'en' | 'pt';
226226
* Note: although the language code type definitions are case-sensitive, this package and the DeepL
227227
* API accept case-insensitive language codes.
228228
*/
229-
export type TargetLanguageCode = CommonLanguageCode | 'en-GB' | 'en-US' | 'pt-BR' | 'pt-PT';
229+
export type TargetLanguageCode =
230+
| CommonLanguageCode
231+
| 'en-GB'
232+
| 'en-US'
233+
| 'pt-BR'
234+
| 'pt-PT'
235+
| 'zh-HANS'
236+
| 'zh-HANT';
230237

231238
/**
232239
* All language codes, including source-only and target-only language codes.

Diff for: src/utils.ts

+4
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ export function buildURLSearchParams(
167167
throw new DeepLError(
168168
"targetLang='pt' is deprecated, please use 'pt-PT' or 'pt-BR' instead.",
169169
);
170+
} else if (targetLang === 'zh') {
171+
throw new DeepLError(
172+
"targetLang='zh' is deprecated, please use 'zh-HANS' or 'zh-HANT' instead.",
173+
);
170174
}
171175

172176
const searchParams = new URLSearchParams({

Diff for: tests/core.ts

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ const internalExampleText: Record<string, string> = {
4545
tr: 'proton ışını',
4646
uk: 'протонний пучок',
4747
zh: '质子束',
48+
'zh-HANS': '质子束',
49+
'zh-HANT': '質子束',
4850
};
4951

5052
export const usingMockServer = process.env.DEEPL_MOCK_SERVER_PORT !== undefined;

0 commit comments

Comments
 (0)