summaryrefslogtreecommitdiffstats
path: root/Tools/i18n
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2001-05-23 16:59:45 (GMT)
committerBarry Warsaw <barry@python.org>2001-05-23 16:59:45 (GMT)
commit128c77d03ae413295f7c7803835788192b7e3315 (patch)
treead0b15c5d8275fdc13fbc4b2f4e81c37ab4aa427 /Tools/i18n
parent54a069f271170b6484c150caee4aa3ea4076a3ee (diff)
downloadcpython-128c77d03ae413295f7c7803835788192b7e3315.zip
cpython-128c77d03ae413295f7c7803835788192b7e3315.tar.gz
cpython-128c77d03ae413295f7c7803835788192b7e3315.tar.bz2
write(): Do two levels of sorting: first sort the individual location
tuples by filename/lineno, then sort the catalog entries by their location tuples.
Diffstat (limited to 'Tools/i18n')
-rwxr-xr-xTools/i18n/pygettext.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Tools/i18n/pygettext.py b/Tools/i18n/pygettext.py
index 804c98c..14a83b4 100755
--- a/Tools/i18n/pygettext.py
+++ b/Tools/i18n/pygettext.py
@@ -325,7 +325,17 @@ class TokenEater:
# The time stamp in the header doesn't have the same format as that
# generated by xgettext...
print >> fp, pot_header % {'time': timestamp, 'version': __version__}
+ # Sort the entries. First sort each particular entry's keys, then
+ # sort all the entries by their first item.
+ reverse = {}
for k, v in self.__messages.items():
+ keys = v.keys()
+ keys.sort()
+ reverse[tuple(keys)] = (k, v)
+ rkeys = reverse.keys()
+ rkeys.sort()
+ for rkey in rkeys:
+ k, v = reverse[rkey]
# If the entry was gleaned out of a docstring, then add a comment
# stating so. This is to aid translators who may wish to skip
# translating some unimportant docstrings.