[Python-checkins] CVS: python/dist/src/Tools/i18n pygettext.py,1.17,1.18

Barry Warsaw bwarsaw@users.sourceforge.net
Thu, 24 May 2001 16:06:16 -0700


Update of /cvsroot/python/python/dist/src/Tools/i18n
In directory usw-pr-cvs1:/tmp/cvs-serv15162

Modified Files:
	pygettext.py 
Log Message:
write(): Aggressively sort all catalog entries, and fix the bug where
there were multiple translatable strings on a single line of source
code.


Index: pygettext.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/i18n/pygettext.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** pygettext.py	2001/05/23 16:59:45	1.17
--- pygettext.py	2001/05/24 23:06:13	1.18
***************
*** 332,374 ****
              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.
!             if reduce(operator.__add__, v.values()):
!                 print >> fp, '#. docstring'
!             # k is the message string, v is a dictionary-set of (filename,
!             # lineno) tuples.  We want to sort the entries in v first by file
!             # name and then by line number.
!             v = v.keys()
!             v.sort()
!             if not options.writelocations:
!                 pass
!             # location comments are different b/w Solaris and GNU:
!             elif options.locationstyle == options.SOLARIS:
!                 for filename, lineno in v:
!                     d = {'filename': filename, 'lineno': lineno}
!                     print >>fp, _('# File: %(filename)s, line: %(lineno)d') % d
!             elif options.locationstyle == options.GNU:
!                 # fit as many locations on one line, as long as the
!                 # resulting line length doesn't exceeds 'options.width'
!                 locline = '#:'
!                 for filename, lineno in v:
!                     d = {'filename': filename, 'lineno': lineno}
!                     s = _(' %(filename)s:%(lineno)d') % d
!                     if len(locline) + len(s) <= options.width:
!                         locline = locline + s
!                     else:
                          print >> fp, locline
!                         locline = "#:" + s
!                 if len(locline) > 2:
!                     print >> fp, locline
!             # TBD: sorting, normalizing
!             print >> fp, 'msgid', normalize(k)
!             print >> fp, 'msgstr ""\n'
  
  
--- 332,376 ----
              keys = v.keys()
              keys.sort()
!             reverse.setdefault(tuple(keys), []).append((k, v))
          rkeys = reverse.keys()
          rkeys.sort()
          for rkey in rkeys:
!             rentries = reverse[rkey]
!             rentries.sort()
!             for k, v in rentries:
!                 # 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.
!                 if reduce(operator.__add__, v.values()):
!                     print >> fp, '#. docstring'
!                 # k is the message string, v is a dictionary-set of (filename,
!                 # lineno) tuples.  We want to sort the entries in v first by
!                 # file name and then by line number.
!                 v = v.keys()
!                 v.sort()
!                 if not options.writelocations:
!                     pass
!                 # location comments are different b/w Solaris and GNU:
!                 elif options.locationstyle == options.SOLARIS:
!                     for filename, lineno in v:
!                         d = {'filename': filename, 'lineno': lineno}
!                         print >>fp, _(
!                             '# File: %(filename)s, line: %(lineno)d') % d
!                 elif options.locationstyle == options.GNU:
!                     # fit as many locations on one line, as long as the
!                     # resulting line length doesn't exceeds 'options.width'
!                     locline = '#:'
!                     for filename, lineno in v:
!                         d = {'filename': filename, 'lineno': lineno}
!                         s = _(' %(filename)s:%(lineno)d') % d
!                         if len(locline) + len(s) <= options.width:
!                             locline = locline + s
!                         else:
!                             print >> fp, locline
!                             locline = "#:" + s
!                     if len(locline) > 2:
                          print >> fp, locline
!                 print >> fp, 'msgid', normalize(k)
!                 print >> fp, 'msgstr ""\n'