summaryrefslogtreecommitdiff
path: root/lang/duke_fix.py
blob: b54596d1a951f38f6f0930024cae208938a85393 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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())+"%")