Updated translate template
added test file
This commit is contained in:
@@ -29,7 +29,8 @@ def translate(_input, lang='RU'):
|
|||||||
"commonJobParams": {},
|
"commonJobParams": {},
|
||||||
"timestamp": int(round(time.time() * 1000))
|
"timestamp": int(round(time.time() * 1000))
|
||||||
},
|
},
|
||||||
"id": 40890008
|
"id": 40890009
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
print(r.json())
|
||||||
return r.json()['result']['translations'][0]['beams'][0]['postprocessed_sentence']
|
return r.json()['result']['translations'][0]['beams'][0]['postprocessed_sentence']
|
||||||
|
|||||||
20
main.py
20
main.py
@@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/pyhton3
|
#!/usr/bin/pyhton3
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
import time
|
||||||
|
|
||||||
from lib.translate import translate
|
from lib.translate import translate
|
||||||
|
|
||||||
@@ -27,19 +29,25 @@ def parsing_file(f):
|
|||||||
_list = _cached.split('\n')
|
_list = _cached.split('\n')
|
||||||
_to_translate = []
|
_to_translate = []
|
||||||
|
|
||||||
_list = [i for i in _list if i != '']
|
|
||||||
for _str in _list:
|
for _str in _list:
|
||||||
if _str.find('%_t') != -1 or _str.find('%_T') != -1:
|
if _str.find('%_t') != -1 or _str.find('%_T') != -1:
|
||||||
|
print(_str)
|
||||||
_to_translate.append(_str)
|
_to_translate.append(_str)
|
||||||
|
|
||||||
return _to_translate
|
return _to_translate
|
||||||
|
|
||||||
|
|
||||||
test_en = parsing_file(name)[0].split('\"')[1].split(' /*')[0]
|
# test_en = parsing_file(name)[0].split('\"')[1].split(' /*')[0]
|
||||||
test = translate(test_en)
|
# test = translate(test_en)
|
||||||
translate_entity = ("\n# ========== %s ==========\n#: %s\nmsgid: \"%s\"\nmsgstr: \"%s\"" % (name, name, test_en, test))
|
# translate_entity = ("\n# ========== %s ==========\n#: %s\nmsgid: \"%s\"\nmsgstr: \"%s\"" % (name, name, test_en, test))
|
||||||
print(translate_entity)
|
# 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():
|
def all_to_translate():
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user