summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-05-16 14:45:58 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-05-16 14:45:58 +0000
commit095d3ca8eb328ddea96744090f21c1d0cfb1c571 (patch)
tree9cd77709da880b26f16c963c9baf68010b53a987
parent1ca5bc0f0c8cf054658ef55419dc9ac0b774bcdf (diff)
unicode: Audited humanize app for unicode compliance.
git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5258 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/humanize/templatetags/humanize.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py
index 425fd9c542..f268042917 100644
--- a/django/contrib/humanize/templatetags/humanize.py
+++ b/django/contrib/humanize/templatetags/humanize.py
@@ -1,4 +1,5 @@
from django.utils.translation import ungettext, ugettext_lazy as _
+from django.utils.encoding import smart_unicode
from django import template
import re
@@ -15,8 +16,8 @@ def ordinal(value):
return value
t = (_('th'), _('st'), _('nd'), _('rd'), _('th'), _('th'), _('th'), _('th'), _('th'), _('th'))
if value % 100 in (11, 12, 13): # special case
- return "%d%s" % (value, t[0])
- return '%d%s' % (value, t[value % 10])
+ return u"%d%s" % (value, t[0])
+ return u'%d%s' % (value, t[value % 10])
register.filter(ordinal)
def intcomma(value):
@@ -24,8 +25,8 @@ def intcomma(value):
Converts an integer to a string containing commas every three digits.
For example, 3000 becomes '3,000' and 45000 becomes '45,000'.
"""
- orig = str(value)
- new = re.sub("^(-?\d+)(\d{3})", '\g<1>,\g<2>', str(value))
+ orig = smart_unicode(value)
+ new = re.sub("^(-?\d+)(\d{3})", '\g<1>,\g<2>', smart_unicode(value))
if orig == new:
return new
else: