Skip to content

Fix: DeepL translation doesn't work for Simplified Chinese#232

Merged
Jeehut merged 3 commits intoFlineDev:mainfrom
mshibanami:fix-deepl-zh-simplified-support
Aug 26, 2021
Merged

Fix: DeepL translation doesn't work for Simplified Chinese#232
Jeehut merged 3 commits intoFlineDev:mainfrom
mshibanami:fix-deepl-zh-simplified-support

Conversation

@mshibanami
Copy link
Copy Markdown
Contributor

(No related issue)

Problem

Suppose you want to translate an English word "Hello" to Simplified Chinese with DeepL API via BartyCrouch.
Currently, BartyCrouch sends a request like this:

https://api-free.deepl.com/v2/translate?source_lang=En&text=Hello&target_lang=Zh-Hans&auth_key={auth key}

But DeepL doesn't allow Zh-Hans for target_lang nor source_lang, so they always return 400 Bad Request.

This is the documentation of what they allow: https://www.deepl.com/docs-api/translating-text/request/

Proposed Changes

  • Set ZH rather than Zh-Hans for target_lang and source_lang
    • I didn't do this for Traditional Chinese because DeepL's ZH is actually for Simplified Chinese but I have no strong opinion. Please feel free to suggest me doing this for Traditional Chinese too.
  • Change the values of target_lang and source_lang to UPPER CASE from Capitalised Case
    • This is a kind of refactoring. As of now, both uppercased and capitalized work fine, but I guess we better to use the documented case.

So this PR will change the above URL into this:

https://api-free.deepl.com/v2/translate?source_lang=EN&text=Hello&target_lang=ZH&auth_key={your auth key}

Copy link
Copy Markdown
Member

@Jeehut Jeehut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, code looks good to me. Merging! 🎉

@Jeehut Jeehut merged commit 29f84e4 into FlineDev:main Aug 26, 2021
@mshibanami
Copy link
Copy Markdown
Contributor Author

Thanks!

@Jeehut
Copy link
Copy Markdown
Member

Jeehut commented Aug 26, 2021

Released in version 4.7.1. 🚀

@mshibanami mshibanami deleted the fix-deepl-zh-simplified-support branch August 27, 2021 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants