Skip to content

Commit b00d5ae

Browse files
authored
Merge pull request #3 from zoulasc/main
Fix msgfmt.py to work with python3 and produce the same output as the…
2 parents 839a2f0 + 7c0e3fc commit b00d5ae

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

bin/msgfmt.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#! /usr/bin/env python
2+
23
# -*- 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>
45

56
"""Generate binary message catalog from textual translation description.
67
@@ -56,10 +57,12 @@ def add(id, str, fuzzy):
5657
def generate():
5758
"Return the generated output."
5859
global MESSAGES
60+
keys = list(MESSAGES.keys())
5961
# the keys are sorted in the .mo file
62+
keys.sort()
6063
offsets = []
6164
ids = strs = ''
62-
for id in MESSAGES.keys():
65+
for id in keys:
6366
# For each string, we need size and file offset. Each string is NUL
6467
# terminated; the NUL does not count into the size.
6568
offsets.append((len(ids), len(id), len(strs), len(MESSAGES[id])))
@@ -87,9 +90,9 @@ def generate():
8790
7*4, # start of key index
8891
7*4+len(keys)*8, # start of value index
8992
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')
9396
return output
9497

9598

messages/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ CFLAGS= $(OPT) $(DEFS)
4444
PACKAGEDIR= $(prefix)/messages
4545
SHELL= /bin/sh
4646
DIRSETGID= chmod g+s
47-
MSGFMT= python2 ../bin/msgfmt-python2.py
47+
MSGFMT= python3 ../bin/msgfmt.py
4848
MSGMERGE= msgmerge
4949

5050
# CVS available languages

0 commit comments

Comments
 (0)