Deepl: use the PRO API endpoint when using a PRO API key. Fixes #278

This commit is contained in:
Marco Bonetti 2023-05-11 13:03:18 +02:00
parent 82b549b646
commit d36b89749f
3 changed files with 8 additions and 3 deletions

View file

@ -4,7 +4,7 @@ Version History
Version 0.9.10 (unreleased)
---------------------------
* Fix link to polib. (#277, thanks @gamboz)
* Deepl: use the PRO API endpoint when using a PRO API key. (#278, thanks @nullcode)
Version 0.9.9

View file

@ -48,8 +48,13 @@ def translate(text, from_language, to_language):
def translate_by_deepl(text, to_language, auth_key):
if auth_key.lower().endswith(":fx"):
endpoint = "https://api-free.deepl.com"
else:
endpoint = "https://api.deepl.com"
r = requests.post(
"https://api-free.deepl.com/v2/translate",
f"{endpoint}/v2/translate",
headers={"Authorization": f"DeepL-Auth-Key {auth_key}"},
data={
"target_lang": to_language.upper(),

View file

@ -17,7 +17,7 @@ interactions:
User-Agent:
- python-requests/2.26.0
method: POST
uri: https://api-free.deepl.com/v2/translate
uri: https://api.deepl.com/v2/translate
response:
body: {string: '{"translations": [{"detected_source_language": "EN", "text": "Salut tout le monde"}]}'}
headers: