54 lines
1.1 KiB
Python
Executable File
54 lines
1.1 KiB
Python
Executable File
#!/usr/bin/pyhton3
|
|
import os
|
|
import re
|
|
import time
|
|
|
|
from lib.translate import translate
|
|
|
|
|
|
# path = "C:\Users\riksl\PycharmProjects\weapon-project-extended"
|
|
|
|
name = "weapongenerator.lua"
|
|
_tmp :str = ""
|
|
|
|
|
|
def _lister(_path) -> list:
|
|
_list: list = []
|
|
try:
|
|
for f in os.walk(_path):
|
|
_list.extend(f)
|
|
break
|
|
return sorted(_list[2])
|
|
except TypeError:
|
|
pass
|
|
|
|
|
|
def parsing_file(f):
|
|
with open(f) as _f:
|
|
_cached = _f.read()
|
|
|
|
_list = _cached.split('\n')
|
|
_to_translate = []
|
|
|
|
for _str in _list:
|
|
if _str.find('%_t') != -1 or _str.find('%_T') != -1:
|
|
_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)
|
|
# parsing_file(name)
|
|
for _str in parsing_file(name):
|
|
print(_str)
|
|
test = re.findall('= "(.*[^/])(?: /\*(.*)\*/)?"%_[t|T]', _str)
|
|
_tmp = _tmp + test[0][0] + '\n'
|
|
|
|
print(translate(_tmp))
|
|
|
|
def all_to_translate():
|
|
pass
|