Changeset 5258
- Timestamp:
- 05/16/07 09:45:58 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/unicode/django/contrib/humanize/templatetags/humanize.py
r5229 r5258 1 1 from django.utils.translation import ungettext, ugettext_lazy as _ 2 from django.utils.encoding import smart_unicode 2 3 from django import template 3 4 import re … … 16 17 t = (_('th'), _('st'), _('nd'), _('rd'), _('th'), _('th'), _('th'), _('th'), _('th'), _('th')) 17 18 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]) 20 21 register.filter(ordinal) 21 22 … … 25 26 For example, 3000 becomes '3,000' and 45000 becomes '45,000'. 26 27 """ 27 orig = s tr(value)28 new = re.sub("^(-?\d+)(\d{3})", '\g<1>,\g<2>', s tr(value))28 orig = smart_unicode(value) 29 new = re.sub("^(-?\d+)(\d{3})", '\g<1>,\g<2>', smart_unicode(value)) 29 30 if orig == new: 30 31 return new
