Edgewall Software

Ticket #8081: i18n_pretty_timedelta.patch

File i18n_pretty_timedelta.patch, 1.5 KB (added by anonymous, 3 years ago)
  • trac/util/datefmt.py

     
    2525 
    2626from trac.core import TracError 
    2727from trac.util.text import to_unicode 
     28from trac.util.translation import _, tag_, N_, gettext 
    2829 
    2930# Date/time utilities 
    3031 
     
    7273    time2 = to_datetime(time2) 
    7374    if time1 > time2: 
    7475        time2, time1 = time1, time2 
    75     units = ((3600 * 24 * 365, 'year',   'years'), 
    76              (3600 * 24 * 30,  'month',  'months'), 
    77              (3600 * 24 * 7,   'week',   'weeks'), 
    78              (3600 * 24,       'day',    'days'), 
    79              (3600,            'hour',   'hours'), 
    80              (60,              'minute', 'minutes')) 
     76    units = ((3600 * 24 * 365, _('year'),   _('years')), 
     77             (3600 * 24 * 30,  _('month'),  _('months')), 
     78             (3600 * 24 * 7,   _('week'),   _('weeks')), 
     79             (3600 * 24,       _('day'),    _('days')), 
     80             (3600,            _('hour'),   _('hours')), 
     81             (60,              _('minute'), _('minutes'))) 
    8182    diff = time2 - time1 
    8283    age_s = int(diff.days * 86400 + diff.seconds) 
    8384    if resolution and age_s < resolution: 
    8485        return '' 
    8586    if age_s <= 60 * 1.9: 
    86         return '%i second%s' % (age_s, age_s != 1 and 's' or '') 
     87        return '%i %s' % (age_s, age_s == 1 and _('second') or _('seconds')) 
    8788    for u, unit, unit_plural in units: 
    8889        r = float(age_s) / float(u) 
    8990        if r >= 1.9: