summaryrefslogtreecommitdiff
path: root/po/compile.py
diff options
context:
space:
mode:
Diffstat (limited to 'po/compile.py')
-rwxr-xr-xpo/compile.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/po/compile.py b/po/compile.py
index a78859a4..373fdcf9 100755
--- a/po/compile.py
+++ b/po/compile.py
@@ -13,7 +13,6 @@ ESCAPES = {
13 'r': '\r', 13 'r': '\r',
14 't': '\t' 14 't': '\t'
15} 15}
16BASE_STRINGS = {}
17 16
18if '--new' in sys.argv: 17if '--new' in sys.argv:
19 MODE = 'new' 18 MODE = 'new'
@@ -85,11 +84,15 @@ def parse_po(src):
85def compile_string(msg_id, msg_str): 84def compile_string(msg_id, msg_str):
86 return msg_id.encode('utf-8') + bytes([0]) + \ 85 return msg_id.encode('utf-8') + bytes([0]) + \
87 msg_str.encode('utf-8') + bytes([0]) 86 msg_str.encode('utf-8') + bytes([0])
88 87
89 88
90if MODE == 'compile': 89if MODE == 'compile':
90 BASE_STRINGS = {}
91 PLURALS = set()
91 for msg_id, msg_str in parse_po('en.po'): 92 for msg_id, msg_str in parse_po('en.po'):
92 BASE_STRINGS[msg_id] = msg_str 93 BASE_STRINGS[msg_id] = msg_str
94 if msg_id.endswith('.0'):
95 PLURALS.add(msg_id[:-2])
93 for src in os.listdir('.'): 96 for src in os.listdir('.'):
94 if src.endswith('.po') and src.split('.')[0] in BUILD_LANGS: 97 if src.endswith('.po') and src.split('.')[0] in BUILD_LANGS:
95 # Make a binary blob with strings sorted by ID. 98 # Make a binary blob with strings sorted by ID.
@@ -100,7 +103,7 @@ if MODE == 'compile':
100 have_ids.add(msg_id) 103 have_ids.add(msg_id)
101 # Take missing strings from the base language. 104 # Take missing strings from the base language.
102 for msg_id in BASE_STRINGS: 105 for msg_id in BASE_STRINGS:
103 if msg_id not in have_ids: 106 if msg_id not in have_ids and not msg_id[:-2] in PLURALS:
104 print(src, 'missing:', msg_id) 107 print(src, 'missing:', msg_id)
105 lang.append((msg_id, BASE_STRINGS[msg_id])) 108 lang.append((msg_id, BASE_STRINGS[msg_id]))
106 for msg_id, msg_str in sorted(lang): 109 for msg_id, msg_str in sorted(lang):