Skip to content

Commit

Permalink
Translators/DeepLTranslator: last attempt, close #268
Browse files Browse the repository at this point in the history
  • Loading branch information
soimort committed Dec 23, 2018
1 parent 0e8aa30 commit 48014ce
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions include/Translators/DeepLTranslator.awk
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function deeplWebTranslateUrl(uri, sl, tl, hl) {
function deeplPostSplit(text, sl, tl, hl,
####
content, data, url) {
data = "{\"jsonrpc\":\"2.0\",\"method\":\"LMT_split_into_sentences\","
data = "{\"jsonrpc\":\"2.0\",\"method\": \"LMT_split_into_sentences\","
data = data "\"params\":{\"texts\":[" parameterize(text, "\"") "]}}"
l(data)
url = "https://www2.deepl.com/jsonrpc"
Expand All @@ -39,7 +39,8 @@ function deeplPostSplit(text, sl, tl, hl,
function deeplPost(sentences, sl, tl, hl,
####
content, data, i, url) {
data = "{\"jsonrpc\":\"2.0\",\"method\":\"LMT_handle_jobs\","
timestamp = getOutput("date +%s%3N")
data = "{\"jsonrpc\":\"2.0\",\"method\": \"LMT_handle_jobs\","
data = data "\"params\":{\"jobs\":["
for (i in sentences) {
if (i > 0) data = data ","
Expand All @@ -49,7 +50,7 @@ function deeplPost(sentences, sl, tl, hl,
data = data "\"lang\":{\"user_preferred_langs\":[\"" hl "\"],"
data = data "\"source_lang_user_selected\":\"" sl "\","
data = data "\"target_lang\":\"" tl "\"},"
data = data "\"priority\":1},\"id\":1}"
data = data "\"priority\":1,\"timestamp\":" timestamp "}}"
l(data)
url = "https://www2.deepl.com/jsonrpc"
content = curlPost(url, data)
Expand Down

0 comments on commit 48014ce

Please sign in to comment.