diff --git a/src/types.ts b/src/types.ts index 1455445..cf87e41 100644 --- a/src/types.ts +++ b/src/types.ts @@ -223,7 +223,14 @@ export type SourceLanguageCode = CommonLanguageCode | 'en' | 'pt'; * Note: although the language code type definitions are case-sensitive, this package and the DeepL * API accept case-insensitive language codes. */ -export type TargetLanguageCode = CommonLanguageCode | 'en-GB' | 'en-US' | 'pt-BR' | 'pt-PT'; +export type TargetLanguageCode = + | CommonLanguageCode + | 'en-GB' + | 'en-US' + | 'pt-BR' + | 'pt-PT' + | 'zh-HANS' + | 'zh-HANT'; /** * All language codes, including source-only and target-only language codes. diff --git a/src/utils.ts b/src/utils.ts index b988450..8e02009 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -167,6 +167,10 @@ export function buildURLSearchParams( throw new DeepLError( "targetLang='pt' is deprecated, please use 'pt-PT' or 'pt-BR' instead.", ); + } else if (targetLang === 'zh') { + throw new DeepLError( + "targetLang='zh' is deprecated, please use 'zh-HANS' or 'zh-HANT' instead.", + ); } const searchParams = new URLSearchParams({ diff --git a/tests/core.ts b/tests/core.ts index d7583e8..5ab5ec2 100644 --- a/tests/core.ts +++ b/tests/core.ts @@ -45,6 +45,8 @@ const internalExampleText: Record = { tr: 'proton ışını', uk: 'протонний пучок', zh: '质子束', + 'zh-HANS': '质子束', + 'zh-HANT': '質子束', }; export const usingMockServer = process.env.DEEPL_MOCK_SERVER_PORT !== undefined;