Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing types for zh-HANS and zh-HANT (fix #58) #62

Merged
merged 2 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 2 additions & 0 deletions tests/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const internalExampleText: Record<string, string> = {
tr: 'proton ışını',
uk: 'протонний пучок',
zh: '质子束',
'zh-HANS': '质子束',
'zh-HANT': '質子束',
};

export const usingMockServer = process.env.DEEPL_MOCK_SERVER_PORT !== undefined;
Expand Down