Updated translate template
added test file
This commit is contained in:
@@ -32,10 +32,9 @@ def translate(_input, lang='RU'):
|
||||
"commonJobParams": {},
|
||||
"timestamp": int(round(time.time() * 1000))
|
||||
},
|
||||
"id": 40890008
|
||||
"id": _id
|
||||
}
|
||||
)
|
||||
print(_id)
|
||||
try:
|
||||
return r.json()['result']['translations'][0]['beams'][0]['postprocessed_sentence']
|
||||
except:
|
||||
|
||||
34
main.py
34
main.py
@@ -1,28 +1,33 @@
|
||||
#!/usr/bin/pyhton3
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
from fnmatch import fnmatch
|
||||
|
||||
from lib.translate import translate
|
||||
|
||||
|
||||
# path = "C:\Users\riksl\PycharmProjects\weapon-project-extended"
|
||||
_path = r'C:/Users/riksl/PycharmProjects/weapon-project-extended/data/scripts/'
|
||||
|
||||
name = "weapongenerator.lua"
|
||||
_tmp :str = ""
|
||||
|
||||
|
||||
def _lister(_path) -> list:
|
||||
_list: list = []
|
||||
try:
|
||||
for f in os.walk(_path):
|
||||
_list.extend(f)
|
||||
pattern = "*.lua"
|
||||
|
||||
for path, subdirs, files in os.scandir(_path):
|
||||
for name in files:
|
||||
if fnmatch(name, pattern):
|
||||
print(os.path.join(path, name))
|
||||
_list.extend(f"{path}/{name}")
|
||||
break
|
||||
return sorted(_list[2])
|
||||
return sorted(_list)
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
|
||||
print(_path)
|
||||
print(_lister(_path))
|
||||
|
||||
|
||||
def parsing_file(f):
|
||||
with open(f) as _f:
|
||||
_cached = _f.read()
|
||||
@@ -37,17 +42,10 @@ def parsing_file(f):
|
||||
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)
|
||||
# parsing_file(name)
|
||||
for _str in parsing_file(name):
|
||||
print(_str)
|
||||
test = re.findall('= "(.*[^/])(?: /\*(.*)\*/)?"%_[t|T]', _str)
|
||||
_tmp = _tmp + test[0][0] + '\n'
|
||||
test = re.findall('= "(.*[^/])(?: /\* (.*)\*/)?"%_[t|T]', _str)
|
||||
# print(test)
|
||||
|
||||
print(translate(_tmp))
|
||||
|
||||
def all_to_translate():
|
||||
pass
|
||||
|
||||
@@ -62,7 +62,7 @@ function WeaponGenerator.generateHeavyCannon(rand, dps, tech, material, rarity)
|
||||
weapon.appearance = WeaponAppearance.Bolter
|
||||
weapon.name = "Heavy Cannon /* Weapon Name*/"%_t
|
||||
weapon.icon = "data/textures/icons/heavycannon.png"
|
||||
weapon.sound = "cannon"%_T
|
||||
weapon.sound = "cannon"
|
||||
weapon.accuracy = 0.95 - rand:getFloat(0, 0.02)
|
||||
|
||||
weapon.damage = damage
|
||||
|
||||
Reference in New Issue
Block a user