summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpo/compile.py25
-rw-r--r--res/lang/es.binbin17761 -> 17901 bytes
-rw-r--r--res/lang/fi.binbin17404 -> 17544 bytes
-rw-r--r--res/lang/ru.binbin26554 -> 26694 bytes
-rw-r--r--res/lang/zh_Hans.binbin15406 -> 16330 bytes
5 files changed, 20 insertions, 5 deletions
diff --git a/po/compile.py b/po/compile.py
index 0bda0a07..a78859a4 100755
--- a/po/compile.py
+++ b/po/compile.py
@@ -13,6 +13,7 @@ ESCAPES = {
13 'r': '\r', 13 'r': '\r',
14 't': '\t' 14 't': '\t'
15} 15}
16BASE_STRINGS = {}
16 17
17if '--new' in sys.argv: 18if '--new' in sys.argv:
18 MODE = 'new' 19 MODE = 'new'
@@ -80,21 +81,35 @@ def parse_po(src):
80 #print(msg_id, '=>', msg_str) 81 #print(msg_id, '=>', msg_str)
81 return pluralized 82 return pluralized
82 83
83 84
85def compile_string(msg_id, msg_str):
86 return msg_id.encode('utf-8') + bytes([0]) + \
87 msg_str.encode('utf-8') + bytes([0])
88
89
84if MODE == 'compile': 90if MODE == 'compile':
91 for msg_id, msg_str in parse_po('en.po'):
92 BASE_STRINGS[msg_id] = msg_str
85 for src in os.listdir('.'): 93 for src in os.listdir('.'):
86 if src.endswith('.po') and src.split('.')[0] in BUILD_LANGS: 94 if src.endswith('.po') and src.split('.')[0] in BUILD_LANGS:
87 # Make a binary blob with strings sorted by ID. 95 # Make a binary blob with strings sorted by ID.
96 have_ids = set()
88 compiled = bytes() 97 compiled = bytes()
89 for msg in sorted(parse_po(src)): 98 lang = parse_po(src)
90 compiled += msg[0].encode('utf-8') + bytes([0]) 99 for msg_id, _ in lang:
91 compiled += msg[1].encode('utf-8') + bytes([0]) 100 have_ids.add(msg_id)
101 # Take missing strings from the base language.
102 for msg_id in BASE_STRINGS:
103 if msg_id not in have_ids:
104 print(src, 'missing:', msg_id)
105 lang.append((msg_id, BASE_STRINGS[msg_id]))
106 for msg_id, msg_str in sorted(lang):
107 compiled += compile_string(msg_id, msg_str)
92 open(f'../res/lang/{src[:-3]}.bin', 'wb').write(compiled) 108 open(f'../res/lang/{src[:-3]}.bin', 'wb').write(compiled)
93 109
94elif MODE == 'new': 110elif MODE == 'new':
95 messages = parse_po('en.po') 111 messages = parse_po('en.po')
96 f = open('new.po', 'wt', encoding='utf-8') 112 f = open('new.po', 'wt', encoding='utf-8')
97 # TODO: plurals
98 for msg_id, _ in messages: 113 for msg_id, _ in messages:
99 print(f'\nmsgid "{msg_id}"\nmsgstr ""\n', file=f) 114 print(f'\nmsgid "{msg_id}"\nmsgstr ""\n', file=f)
100 115
diff --git a/res/lang/es.bin b/res/lang/es.bin
index 50593ebd..d53d7e74 100644
--- a/res/lang/es.bin
+++ b/res/lang/es.bin
Binary files differ
diff --git a/res/lang/fi.bin b/res/lang/fi.bin
index 693bbcfb..493d2b37 100644
--- a/res/lang/fi.bin
+++ b/res/lang/fi.bin
Binary files differ
diff --git a/res/lang/ru.bin b/res/lang/ru.bin
index 304b2e53..b3e234da 100644
--- a/res/lang/ru.bin
+++ b/res/lang/ru.bin
Binary files differ
diff --git a/res/lang/zh_Hans.bin b/res/lang/zh_Hans.bin
index 56e2bd9e..dba895cb 100644
--- a/res/lang/zh_Hans.bin
+++ b/res/lang/zh_Hans.bin
Binary files differ