Index: msgfmt.py =================================================================== --- msgfmt.py (revision 59997) +++ msgfmt.py (working copy) @@ -1,6 +1,6 @@ #! /usr/bin/env python # -*- coding: iso-8859-1 -*- -# Written by Martin v. Löwis +# Written by Martin v. Löwis """Generate binary message catalog from textual translation description. @@ -56,17 +56,16 @@ def generate(): "Return the generated output." global MESSAGES - keys = MESSAGES.keys() + keys = sorted(MESSAGES.keys()) # the keys are sorted in the .mo file - keys.sort() offsets = [] - ids = strs = '' + ids = strs = b'' for id in keys: # For each string, we need size and file offset. Each string is NUL # terminated; the NUL does not count into the size. offsets.append((len(ids), len(id), len(strs), len(MESSAGES[id]))) - ids += id + '\0' - strs += MESSAGES[id] + '\0' + ids += id.encode('utf-8') + b'\0' + strs += MESSAGES[id].encode('utf-8') + b'\0' output = '' # The header is 7 32-bit unsigned integers. We don't use hash tables, so # the keys start right after the index tables.