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

Correction of typo in choice and support for older versions of "requests" module #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import argparse
import re
import requests
import json

DEEP_L = 'https://deepl.com/jsonrpc'

Expand All @@ -15,13 +16,13 @@ def main():
'-t', '--target',
default='EN',
dest='target_lang',
choices=['EN', 'DE', 'FR', 'ES', 'IT', 'NL', 'PL', 'auto'],
choices=['EN', 'DE', 'FR', 'ES', 'IT', 'NL', 'PL'],
help="The language to translate into. Defaults to English.")
parser.add_argument(
'-s', '--source',
default='auto',
dest='source_lang',
choices=['DE', 'EN', 'FR', 'ES', 'IT', 'NL', 'PL'],
choices=['DE', 'EN', 'FR', 'ES', 'IT', 'NL', 'PL', 'auto'],
help="The language to translate from. Defaults to 'auto'.")
parser.add_argument(
'text',
Expand All @@ -43,7 +44,7 @@ def main():
"target_lang": args.target_lang},
"priority": 1}}

req = requests.post(DEEP_L, json=payload)
req = requests.post(DEEP_L, data=json.dumps(payload))

if req.ok:
translations = req.json()['result']['translations']
Expand Down