Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 128c77d

Browse files
committed
write(): Do two levels of sorting: first sort the individual location
tuples by filename/lineno, then sort the catalog entries by their location tuples.
1 parent 54a069f commit 128c77d

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Tools/i18n/pygettext.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,17 @@ def write(self, fp):
325325
# The time stamp in the header doesn't have the same format as that
326326
# generated by xgettext...
327327
print >> fp, pot_header % {'time': timestamp, 'version': __version__}
328+
# Sort the entries. First sort each particular entry's keys, then
329+
# sort all the entries by their first item.
330+
reverse = {}
328331
for k, v in self.__messages.items():
332+
keys = v.keys()
333+
keys.sort()
334+
reverse[tuple(keys)] = (k, v)
335+
rkeys = reverse.keys()
336+
rkeys.sort()
337+
for rkey in rkeys:
338+
k, v = reverse[rkey]
329339
# If the entry was gleaned out of a docstring, then add a comment
330340
# stating so. This is to aid translators who may wish to skip
331341
# translating some unimportant docstrings.

0 commit comments

Comments
 (0)