From 620b76f5f89abd1ce96ac2a85e66026a9e74c2ed Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Sat, 28 Sep 2019 19:47:06 +0200 Subject: [PATCH] translation file new generated --- i18n.py | 22 ++++++++++++---------- locale/techage.de.tr | 1 + locale/template.txt | 1 + 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/i18n.py b/i18n.py index 6f85a74..e91fe80 100755 --- a/i18n.py +++ b/i18n.py @@ -34,13 +34,14 @@ def read_lua_file_strings(lua_file): def inport_tr_file(tr_file): dOut = {} - for line in open(tr_file, "r").readlines(): - s = line.strip() - if s == "" or s[0] == "#": - continue - match = pattern_tr.match(s) - if match: - dOut[match.group(1)] = match.group(2) + if os.path.exists(tr_file): + for line in open(tr_file, "r").readlines(): + s = line.strip() + if s == "" or s[0] == "#": + continue + match = pattern_tr.match(s) + if match: + dOut[match.group(1)] = match.group(2) return dOut def generate_template(templ_file): @@ -59,7 +60,8 @@ def generate_template(templ_file): def update_tr_file(lNew, mod_name, tr_file): lOut = ["# textdomain: %s\n" % mod_name] - shutil.copyfile(tr_file, tr_file+".old") + if os.path.exists(tr_file): + shutil.copyfile(tr_file, tr_file+".old") dOld = inport_tr_file(tr_file) for key in lNew: val = dOld.get(key, "") @@ -71,8 +73,8 @@ def update_tr_file(lNew, mod_name, tr_file): open(tr_file, "w").write("\n".join(lOut)) data = generate_template("./locale/template.txt") -update_tr_file(data, "techage", "./locale/techage.de.tr") -update_tr_file(data, "techage", "./locale/techage.fr.tr") #update_tr_file(data, "mymod", "./locale/mymod.de.tr") #update_tr_file(data, "mymod", "./locale/mymod.fr.tr") +update_tr_file(data, "techage", "./locale/techage.de.tr") +update_tr_file(data, "techage", "./locale/techage.fr.tr") print("Done.\n") diff --git a/locale/techage.de.tr b/locale/techage.de.tr index 0245cb3..0ef86b5 100644 --- a/locale/techage.de.tr +++ b/locale/techage.de.tr @@ -133,6 +133,7 @@ TA3 Derrick=TA3 Bohrturm TA3 Detector=TA3 Detektor TA3 Drill Bit=TA3 Bohrgestänge TA3 Ele Fab=TA3 E-Fabrik +TA3 Funnel=TA3 Trichter TA3 Furnace Firebox=TA3 Ofen-Feuerkiste TA3 Generator=TA3 Generator TA3 Gravel Sieve=TA3 Kiessieb diff --git a/locale/template.txt b/locale/template.txt index fa3b38d..268ee42 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -131,6 +131,7 @@ TA3 Derrick= TA3 Detector= TA3 Drill Bit= TA3 Ele Fab= +TA3 Funnel= TA3 Furnace Firebox= TA3 Generator= TA3 Gravel Sieve=