mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	unicode: Audited humanize app for unicode compliance.
git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5258 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
		| @@ -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: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user