Skip to content

Commit 29f84e4

Browse files
authored
Merge pull request #232 from mshibanami/fix-deepl-zh-simplified-support
Fix: DeepL translation doesn't work for Simplified Chinese
2 parents fdca40c + 5767dac commit 29f84e4

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ If needed, pluralize to `Tasks`, `PRs` or `Authors` and list multiple entries se
2727
### Removed
2828
- None.
2929
### Fixed
30-
- None.
30+
- Fixed that DeepL translation doesn't work for Simplified Chinese
31+
PR: [#232](https://github.com/Flinesoft/BartyCrouch/pull/232) | Author: [Manabu Nakazawa](https://github.com/mshibanami)
3132
### Security
3233
- None.
3334

Sources/BartyCrouchTranslator/DeeplApi/DeepLApi.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ extension DeepLApi: Endpoint {
6565
switch self {
6666
case let .translate(texts, sourceLanguage, targetLanguage, apiKey):
6767
urlParameters["text"] = .array(texts)
68-
urlParameters["source_lang"] = .string(sourceLanguage.rawValue.capitalized)
69-
urlParameters["target_lang"] = .string(targetLanguage.rawValue.capitalized)
68+
urlParameters["source_lang"] = sourceLanguage.deepLParameterValue
69+
urlParameters["target_lang"] = targetLanguage.deepLParameterValue
7070
urlParameters["auth_key"] = .string(apiKey)
7171
}
7272

@@ -87,3 +87,15 @@ extension DeepLApi: Endpoint {
8787
}
8888
}
8989
}
90+
91+
private extension Language {
92+
var deepLParameterValue: QueryParameterValue {
93+
switch self {
94+
case .chineseSimplified:
95+
return .string("ZH")
96+
97+
default:
98+
return .string(rawValue.uppercased())
99+
}
100+
}
101+
}

0 commit comments

Comments
 (0)