-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmake_trans_tables.py
executable file
·47 lines (40 loc) · 1.18 KB
/
make_trans_tables.py
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
47
#!/usr/bin/env python3
import os
import sys
import json
from defaults import *
def make_trans_table(lang_code):
trans_table_fname = os.path.join("aliases", "meta-aliases-{}.json".format(lang_code))
prev = {}
l = json.load(open(trans_table_fname))
for key, alias, col, description in l:
prev[key] = [alias, col, description]
mdata = []
for key in data["meta_types"]:
if key in prev:
alias, col, description = prev[key]
else:
alias, col, description = "", None, ""
mdata.append([
"\"{}\"".format(key),
"\"{}\"".format(alias),
"\"{}\"".format(col) if col is not None else "null",
"\"{}\"".format(description),
])
result = "[\n"
for i, r in enumerate(mdata):
if i < len(mdata) - 1:
r.append(",")
else:
r.append("")
result += """ [{:<25}, {:<25}, {:<20}, {}]{}\n""".format(*r)
result+= "]"
f = open(trans_table_fname, "w")
f.write(result)
f.close()
if __name__ == "__main__":
for lang_code in [
"en",
"cs"
]:
make_trans_table(lang_code)