1185: Port lang scripts to Python3 r=heinrich5991 a=rffontenelle

Scripts for managing translations are currently available for Python 2. DDNet already uses Python 3, so it make sense IMO to have these scripts using this version as well.

Co-authored-by: Rafael Fontenelle <rafaelff@gnome.org>
This commit is contained in:
bors[bot] 2018-07-06 12:14:46 +00:00
commit 861746a641
4 changed files with 8 additions and 8 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import twlang
import sys
@ -13,7 +13,7 @@ for lang in langs:
empty = 0
supported = 0
unused = 0
for tran, (_, expr, _) in trans.iteritems():
for tran, (_, expr, _) in trans.items():
if not expr:
empty += 1
else:

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import twlang
import sys
@ -28,7 +28,7 @@ if delete_unused or append_missing:
local = twlang.localizes()
if append_missing:
supported = []
for tran, (start, expr, end) in trans.iteritems():
for tran, (start, expr, end) in trans.items():
if delete_unused and tran not in local:
content[start:end] = [None]*(end-start)
if append_missing and tran in local:

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import twlang
import sys
@ -8,6 +8,6 @@ if len(sys.argv) < 2:
infile = sys.argv[1]
trans = twlang.translations(infile)
for tran, (_, expr, _) in trans.iteritems():
for tran, (_, expr, _) in trans.items():
if tran == expr:
print(tran)

View file

@ -12,7 +12,7 @@ def decode(fileobj, elements_per_key):
data = {}
current_key = None
for index, line in enumerate(fileobj):
line = line.decode("utf-8-sig").encode("utf-8")
line = line.encode("utf-8").decode("utf-8-sig")
line = line[:-1]
if line and line[-1] == "\r":
line = line[:-1]
@ -60,7 +60,7 @@ def check_folder(path):
def languages():
index = decode(open("../index.txt"), 2)
langs = {"../"+key+".txt" : [key]+elements for key, elements in index.iteritems()}
langs = {"../"+key+".txt" : [key]+elements for key, elements in index.items()}
return langs