#5017 NORM Update.: l10n incompatible journal i18n plurals

Zarro Boogs per Child bugtracker at laptop.org
Sat Dec 15 11:41:12 EST 2007


#5017: l10n incompatible journal i18n plurals
-------------------------------+--------------------------------------------
  Reporter:  xavi              |       Owner:  tomeu   
      Type:  defect            |      Status:  new     
  Priority:  normal            |   Milestone:  Update.1
 Component:  journal-activity  |     Version:          
Resolution:                    |    Keywords:  i18n    
  Verified:  0                 |  
-------------------------------+--------------------------------------------

Comment(by tomeu):

 I'm afraid my last patch didn't quite fixed it. We need to do the
 following hack so xgettext export the plural forms as such.

 {{{
 diff --git a/misc.py b/misc.py
 index b1b8144..cbdc9dd 100644
 --- a/misc.py
 +++ b/misc.py
 @@ -15,7 +15,7 @@
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 USA

  from gettext import gettext as _
 -from gettext import ngettext
 +import gettext
  import logging
  import time
  import traceback
 @@ -93,6 +93,26 @@ AND = _(' and ')
  COMMA = _(', ')
  RIGHT_NOW = _('Right now')

 +# Explanation of the following hack:
 +# The xgettext utility extracts plural forms by reading the strings
 included as
 +# parameters of ngettext(). As our plurals are not passed to ngettext()
 +# straight away because there needs to be a calculation before we know
 which
 +# strings need to be used, then we need to call ngettext() in a fake way
 so
 +# xgettext will pick them up as plurals.
 +
 +def ngettext(singular, plural, n): pass
 +
 +ngettext('%d year',   '%d years',   1)
 +ngettext('%d month',  '%d months',  1)
 +ngettext('%d week',   '%d weeks',   1)
 +ngettext('%d day',    '%d days',    1)
 +ngettext('%d hour',   '%d hours',   1)
 +ngettext('%d minute', '%d minutes', 1)
 +
 +del ngettext
 +
 +# End of plurals hack
 +
  def _get_elapsed_string(timestamp, max_levels=2):
      levels = 0
      result = ''
 @@ -107,7 +127,8 @@ def _get_elapsed_string(timestamp, max_levels=2):
                  else:
                      result += COMMA

 -            result += ngettext(name_singular, name_plural, elapsed_units)
 % elapsed_units
 +            result += gettext.ngettext(name_singular, name_plural,
 +                    elapsed_units) % elapsed_units

              elapsed_seconds -= elapsed_units * factor
              levels += 1
 }}}

-- 
Ticket URL: <http://dev.laptop.org/ticket/5017#comment:11>
One Laptop Per Child <http://dev.laptop.org>
OLPC bug tracking system



More information about the Bugs mailing list