[Mailman-i18n] sorting pygettext.py output
Tokio Kikuchi
tkikuchi@is.kochi-u.ac.jp
Sat, 19 May 2001 22:53:39 +0900
Hi,
I found it a bit hard task to follow up the versions of mailman-i18n
because pygettext.py output is random order.
Following patch and executing the script with `--style sort' option
make the output more friendly for translaters, I believe.
Cheers,
Tokio Kikuchi
--- pygettext.py.orig Sat May 19 22:36:57 2001
+++ pygettext.py Sat May 19 22:40:43 2001
@@ -100,6 +100,7 @@
Solaris # File: filename, line: line-number
GNU #: filename:line
+ sort (slightly modified GNU with filename/line order)
The style name is case insensitive. GNU style is the default.
@@ -288,7 +289,27 @@
# The time stamp in the header doesn't have the same format
# as that generated by xgettext...
print pot_header % {'time': timestamp, 'version': __version__}
- for k, v in self.__messages.items():
+ if options.locationstyle == options.SORT:
+ messages = {}
+ for k, v in self.__messages.items():
+ file_line = []
+ i = 0
+ for filename, lineno in v:
+ file_line[i:] = ['#: %s:%05d\n'% (filename,lineno)]
+ i = i + 1
+ file_line.sort()
+ s = ''
+ for f in file_line:
+ s = s + f
+ messages[s] = k
+ x = messages.keys()
+ x.sort()
+ for s in x:
+ print s,
+ print 'msgid', normalize(messages[s])
+ print 'msgstr ""\n'
+ else:
+ for k, v in self.__messages.items():
if not options.writelocations:
pass
# location comments are different b/w Solaris and GNU:
@@ -336,6 +357,7 @@
# constants
GNU = 1
SOLARIS = 2
+ SORT = 3
# defaults
extractall = 0 # FIXME: currently this option has no effect at all.
escape = 0
@@ -351,6 +373,7 @@
options = Options()
locations = {'gnu' : options.GNU,
'solaris' : options.SOLARIS,
+ 'sort' : options.SORT,
}
# parse options