Big refactor of bl_i18n_utils, switching to an object-based model. Still a bit wip.

Notes:
* Most tools here have been updated, only a few (unused :p ) features should be missing. But some updates are rough for now, and performances are globally worse currently, will address this later (this is only really noticeable when you work over the whole repo, anyway ;) ).
* This update breaks "edit translations" addon, will fix it later, once core (i.e. this module) is considered stable again!
This commit is contained in:
2013-01-12 16:49:06 +00:00
parent 68d83f4140
commit 55e3912f25
13 changed files with 1088 additions and 684 deletions

View File

@@ -25,8 +25,7 @@
# * Copy pos from branches advanced enough.
# * Clean pos in trunk.
# * Compile pos in trunk in mos, keeping track of those failing.
# * Remove pos, mos (and their dirs) that failed to compile or
# are no more present in trunk.
# * Remove pos, mos (and their dirs) that failed to compile or are no more present in trunk.
import subprocess
import os
@@ -50,25 +49,6 @@ LANGUAGES_FILE = settings.LANGUAGES_FILE
PY3 = settings.PYTHON3_EXEC
def find_matching_po(languages, stats):
"""Match languages defined in LANGUAGES setting to relevant po, if possible!"""
ret = []
for uid, label, org_key in languages:
key = org_key
if key not in stats:
# Try to simplify the key (eg from es_ES to es).
if '_' in org_key:
key = org_key[0:org_key.index('_')]
if '@' in org_key:
key = key + org_key[org_key.index('@'):]
if key in stats:
ret.append((stats[key], uid, label, org_key))
else:
# Mark invalid entries, so that we can put them in the languages file,
# but commented!
ret.append((0.0, -uid, label, org_key))
return ret
def main():
import argparse
parser = argparse.ArgumentParser(description=""
@@ -99,7 +79,8 @@ def main():
os.remove(po)
# Copy pos from branches.
cmd = [PY3, "./import_po_from_branches.py", "-s"]
#cmd = [PY3, "./import_po_from_branches.py", "-s"]
cmd = [PY3, "./import_po_from_branches.py"]
if args.threshold is not None:
cmd += ["-t", str(args.threshold)]
if args.langs:
@@ -124,7 +105,8 @@ def main():
if args.langs and lang not in args.langs:
continue
cmd = [PY3, "./clean_po.py", "-t", "-s", lang]
#cmd = [PY3, "./clean_po.py", "-t", "-s", lang]
cmd = [PY3, "./clean_po.py", "-t", lang]
t = subprocess.call(cmd)
if t:
ret = t