diff options
author | Jesusaves <cpntb1@ymail.com> | 2021-10-29 19:24:53 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2021-10-29 19:24:53 -0300 |
commit | 071e2d33081c6f27a4f6e6794c269815a7777ba7 (patch) | |
tree | 1e90bbb1fa5c5e1b436612ddbacd3bfa16f84bc4 | |
parent | 0caca41237854b11041cc95da55850d944fefcea (diff) | |
download | tools-071e2d33081c6f27a4f6e6794c269815a7777ba7.tar.gz tools-071e2d33081c6f27a4f6e6794c269815a7777ba7.tar.bz2 tools-071e2d33081c6f27a4f6e6794c269815a7777ba7.tar.xz tools-071e2d33081c6f27a4f6e6794c269815a7777ba7.zip |
Utility tool for Duke M
-rwxr-xr-x | lang/duke_fix.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/lang/duke_fix.py b/lang/duke_fix.py new file mode 100755 index 0000000..b54596d --- /dev/null +++ b/lang/duke_fix.py @@ -0,0 +1,46 @@ +#!/usr/bin/python3 +# This converts lang files in po files for Duke M + +import polib, traceback +from copy import copy + +dc={} +s=True +k="" + +f=open("lang_de.txt", "r") + +for l in f: + x=l.replace("\n", "") + if not s: + s=True + continue + elif k == "": + k=copy(x) + continue + else: + dc[k]=copy(x) + s=False; k="" + continue + +f.close() +print("Total strings loaded: %d" % len(dc)) + +po=polib.pofile('in/de.po') +cnt=0 +print("Current progress: "+str(po.percent_translated())+"%") +for e in po: + try: + if (dc[e.msgid] != ""): + cnt+=1 + e.msgstr=copy(dc[e.msgid]) + except: + traceback.print_exc() + print("Faulty: %s" % e.msgid) + +po.save() +print("Manipulated %d strings." % cnt) +print("Progress afterwards:"+str(po.percent_translated())+"%") + + + |