added find strings to translate in file
This commit is contained in:
35
lib/translate.py
Normal file
35
lib/translate.py
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/pyhton3
|
||||
import requests
|
||||
import time
|
||||
|
||||
|
||||
def translate(_input):
|
||||
url = "https://www2.deepl.com/jsonrpc"
|
||||
|
||||
r = requests.post(
|
||||
url,
|
||||
json = {
|
||||
"jsonrpc":"2.0",
|
||||
"method": "LMT_handle_jobs",
|
||||
"params": {
|
||||
"jobs":[{
|
||||
"kind":"default",
|
||||
"raw_en_sentence": _input,
|
||||
"raw_en_context_before":[],
|
||||
"raw_en_context_after":[],
|
||||
"preferred_num_beams":4,
|
||||
"quality":"fast"
|
||||
}],
|
||||
"lang":{
|
||||
"user_preferred_langs":["EN"],
|
||||
"source_lang_user_selected":"auto",
|
||||
"target_lang":"RU"
|
||||
},
|
||||
"priority":-1,
|
||||
"commonJobParams":{},
|
||||
"timestamp": int(round(time.time() * 1000))
|
||||
},
|
||||
"id": 40890008
|
||||
}
|
||||
)
|
||||
return r.json()['result']['translations'][0]['beams'][0]['postprocessed_sentence']
|
||||
Reference in New Issue
Block a user