Fixes in paramecio2
This commit is contained in:
parent
348f3f06f1
commit
59c1e30863
3 changed files with 101 additions and 4 deletions
|
|
@ -28,6 +28,7 @@ import re
|
|||
from pathlib import Path
|
||||
from importlib import import_module
|
||||
from paramecio2.libraries.i18n import I18n
|
||||
from paramecio2.libraries.slugify import slugify
|
||||
try:
|
||||
from settings import config
|
||||
except:
|
||||
|
|
@ -45,6 +46,12 @@ ignored=re.compile(r'^[__|\.].*$')
|
|||
lang_p=re.compile(r"I18n\.lang\('(.*?)',\s+'(.*?)',\s+'(.*?)'\)")
|
||||
lang_t=re.compile(r"\${lang\('(.*?)',\s+'(.*?)',\s+'(.*?)'\)\}")
|
||||
|
||||
lang_s=re.compile(r"i18n\.slang\('(.*?)',\s+'(.*?)'\)")
|
||||
lang_ts=re.compile(r"\${slang\('(.*?)',\s+'(.*?)'\)\}")
|
||||
|
||||
lang_tl=re.compile(r"i18n\.tlang\('(.*?)'\)")
|
||||
lang_ttl=re.compile(r"\${tlang\('(.*?)'\)\}")
|
||||
|
||||
tmp_lang={}
|
||||
|
||||
def start():
|
||||
|
|
@ -53,12 +60,16 @@ def start():
|
|||
|
||||
global lang_p
|
||||
global lang_t
|
||||
global lang_s
|
||||
global lang_tl
|
||||
global lang_ts
|
||||
global lang_ttl
|
||||
|
||||
# Module to search a file where save the file.
|
||||
|
||||
parser = argparse.ArgumentParser(description='A tool for create python language files')
|
||||
|
||||
parser.add_argument('--module', help='The module where search lang files', required=False)
|
||||
parser.add_argument('--module', help='The module where search lang files', required=True)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
@ -86,7 +97,7 @@ def start():
|
|||
|
||||
exit(1)
|
||||
|
||||
scandir(path, path_save)
|
||||
scandir(path, path_save, module_base)
|
||||
|
||||
#Save the files
|
||||
|
||||
|
|
@ -155,7 +166,7 @@ def start():
|
|||
|
||||
pass
|
||||
|
||||
def scandir(path, module_search=''):
|
||||
def scandir(path, module_search='', module_base=None):
|
||||
|
||||
list=os.listdir(path)
|
||||
|
||||
|
|
@ -177,6 +188,19 @@ def scandir(path, module_search=''):
|
|||
match_p=lang_p.findall(line)
|
||||
match_t=lang_t.findall(line)
|
||||
|
||||
match_s=lang_s.findall(line)
|
||||
match_ts=lang_ts.findall(line)
|
||||
|
||||
match_tl=lang_tl.findall(line)
|
||||
match_ttl=lang_ttl.findall(line)
|
||||
|
||||
"""
|
||||
global lang_s
|
||||
global lang_tl
|
||||
global lang_ts
|
||||
global lang_ttl
|
||||
"""
|
||||
|
||||
if match_p!=None:
|
||||
|
||||
for m in match_p:
|
||||
|
|
@ -207,7 +231,45 @@ def scandir(path, module_search=''):
|
|||
tmp_lang[module]=tmp_lang.get(module, {})
|
||||
|
||||
tmp_lang[module][symbol]=tmp_lang[module].get(symbol, text_default)
|
||||
|
||||
|
||||
if module_base:
|
||||
|
||||
if match_s!=None:
|
||||
|
||||
for m in match_s:
|
||||
module=base_module
|
||||
symbol=m[0]
|
||||
text_default=m[1]
|
||||
|
||||
tmp_lang[module]=tmp_lang.get(module, {})
|
||||
tmp_lang[module][symbol]=tmp_lang[module].get(symbol, text_default)
|
||||
|
||||
for m in match_ts:
|
||||
module=base_module
|
||||
symbol=m[0]
|
||||
text_default=m[1]
|
||||
|
||||
tmp_lang[module]=tmp_lang.get(module, {})
|
||||
tmp_lang[module][symbol]=tmp_lang[module].get(symbol, text_default)
|
||||
|
||||
|
||||
for m in match_tl:
|
||||
module=base_module
|
||||
symbol=slugify(m[0])
|
||||
text_default=m[0]
|
||||
|
||||
tmp_lang[module]=tmp_lang.get(module, {})
|
||||
tmp_lang[module][symbol]=tmp_lang[module].get(symbol, text_default)
|
||||
|
||||
for m in match_ttl:
|
||||
module=base_module
|
||||
symbol=slugify(m[0][:40])
|
||||
text_default=m[0]
|
||||
|
||||
tmp_lang[module]=tmp_lang.get(module, {})
|
||||
tmp_lang[module][symbol]=tmp_lang[module].get(symbol, text_default)
|
||||
|
||||
|
||||
|
||||
f.close()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue