|
1 | 1 | #! /usr/bin/env python |
| 2 | + |
2 | 3 | # -*- coding: iso-8859-1 -*- |
3 | | -# Written by Martin v. Löwis <loewis@informatik.hu-berlin.de> |
| 4 | +# Written by Martin v. Loewis <loewis@informatik.hu-berlin.de> |
4 | 5 |
|
5 | 6 | """Generate binary message catalog from textual translation description. |
6 | 7 |
|
@@ -56,10 +57,12 @@ def add(id, str, fuzzy): |
56 | 57 | def generate(): |
57 | 58 | "Return the generated output." |
58 | 59 | global MESSAGES |
| 60 | + keys = list(MESSAGES.keys()) |
59 | 61 | # the keys are sorted in the .mo file |
| 62 | + keys.sort() |
60 | 63 | offsets = [] |
61 | 64 | ids = strs = '' |
62 | | - for id in MESSAGES.keys(): |
| 65 | + for id in keys: |
63 | 66 | # For each string, we need size and file offset. Each string is NUL |
64 | 67 | # terminated; the NUL does not count into the size. |
65 | 68 | offsets.append((len(ids), len(id), len(strs), len(MESSAGES[id]))) |
@@ -87,9 +90,9 @@ def generate(): |
87 | 90 | 7*4, # start of key index |
88 | 91 | 7*4+len(keys)*8, # start of value index |
89 | 92 | 0, 0) # size and offset of hash table |
90 | | - output += array.array("i", offsets).tostring() |
91 | | - output += ids |
92 | | - output += strs |
| 93 | + output += array.array("i", offsets).tobytes() |
| 94 | + output += bytes(ids, 'latin-1') |
| 95 | + output += bytes(strs, 'latin-1') |
93 | 96 | return output |
94 | 97 |
|
95 | 98 |
|
|
0 commit comments