Django

Code

Changeset 5258

Show
Ignore:
Timestamp:
05/16/07 09:45:58 (1 year ago)
Author:
mtredinnick
Message:

unicode: Audited humanize app for unicode compliance.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/unicode/django/contrib/humanize/templatetags/humanize.py

    r5229 r5258  
    11from django.utils.translation import ungettext, ugettext_lazy as _ 
     2from django.utils.encoding import smart_unicode 
    23from django import template 
    34import re 
     
    1617    t = (_('th'), _('st'), _('nd'), _('rd'), _('th'), _('th'), _('th'), _('th'), _('th'), _('th')) 
    1718    if value % 100 in (11, 12, 13): # special case 
    18         return "%d%s" % (value, t[0]) 
    19     return '%d%s' % (value, t[value % 10]) 
     19        return u"%d%s" % (value, t[0]) 
     20    return u'%d%s' % (value, t[value % 10]) 
    2021register.filter(ordinal) 
    2122 
     
    2526    For example, 3000 becomes '3,000' and 45000 becomes '45,000'. 
    2627    """ 
    27     orig = str(value) 
    28     new = re.sub("^(-?\d+)(\d{3})", '\g<1>,\g<2>', str(value)) 
     28    orig = smart_unicode(value) 
     29    new = re.sub("^(-?\d+)(\d{3})", '\g<1>,\g<2>', smart_unicode(value)) 
    2930    if orig == new: 
    3031        return new