Updated translate template

added test file
This commit is contained in:
bacon
2023-08-26 12:12:22 +03:00
parent 64f7089f2e
commit 21a54e1585
2 changed files with 16 additions and 7 deletions

View File

@@ -29,7 +29,8 @@ def translate(_input, lang='RU'):
"commonJobParams": {},
"timestamp": int(round(time.time() * 1000))
},
"id": 40890008
"id": 40890009
}
)
print(r.json())
return r.json()['result']['translations'][0]['beams'][0]['postprocessed_sentence']

20
main.py
View File

@@ -1,5 +1,7 @@
#!/usr/bin/pyhton3
import os
import re
import time
from lib.translate import translate
@@ -27,19 +29,25 @@ def parsing_file(f):
_list = _cached.split('\n')
_to_translate = []
_list = [i for i in _list if i != '']
for _str in _list:
if _str.find('%_t') != -1 or _str.find('%_T') != -1:
print(_str)
_to_translate.append(_str)
return _to_translate
test_en = parsing_file(name)[0].split('\"')[1].split(' /*')[0]
test = translate(test_en)
translate_entity = ("\n# ========== %s ==========\n#: %s\nmsgid: \"%s\"\nmsgstr: \"%s\"" % (name, name, test_en, test))
print(translate_entity)
# test_en = parsing_file(name)[0].split('\"')[1].split(' /*')[0]
# test = translate(test_en)
# translate_entity = ("\n# ========== %s ==========\n#: %s\nmsgid: \"%s\"\nmsgstr: \"%s\"" % (name, name, test_en, test))
# print(translate_entity)
# parsing_file(name)
for _str in parsing_file(name):
print(_str)
test = re.findall('= "(.*[^/])(?: /\*(.*)\*/)?"%_[t|T]', _str)
time.sleep(5)
print(test)
print(translate(test[0][0]), test[0][0])
def all_to_translate():
pass