mirror of
https://github.com/Hopiu/django-rosetta.git
synced 2026-05-28 05:54:00 +00:00
Deepl: use the PRO API endpoint when using a PRO API key. Fixes #278
This commit is contained in:
parent
82b549b646
commit
d36b89749f
3 changed files with 8 additions and 3 deletions
2
CHANGES
2
CHANGES
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue