Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #14807 -- Ensure that boolean values aren't localized as T.rue …

…and Fa.lse because of the thousand separator. Thanks to vanschelven for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14804 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit ac91d5ef086f466c27e77157c67fe4f1df9b7557 1 parent 5bc0ec4
Russell Keith-Magee authored December 04, 2010
5  django/utils/formats.py
@@ -6,6 +6,7 @@
6 6
 from django.utils.importlib import import_module
7 7
 from django.utils.encoding import smart_str
8 8
 from django.utils import dateformat, numberformat, datetime_safe
  9
+from django.utils.safestring import mark_safe
9 10
 
10 11
 # format_cache is a mapping from (format_type, lang) to the format string.
11 12
 # By using the cache, it is possible to avoid running get_format_modules
@@ -114,7 +115,9 @@ def localize(value, use_l10n=None):
114 115
     If use_l10n is provided and is not None, that will force the value to
115 116
     be localized (or not), overriding the value of settings.USE_L10N.
116 117
     """
117  
-    if isinstance(value, (decimal.Decimal, float, int, long)):
  118
+    if isinstance(value, bool):
  119
+        return mark_safe(unicode(value))
  120
+    elif isinstance(value, (decimal.Decimal, float, int, long)):
118 121
         return number_format(value, use_l10n=use_l10n)
119 122
     elif isinstance(value, datetime.datetime):
120 123
         return date_format(value, 'DATETIME_FORMAT', use_l10n=use_l10n)
1  tests/regressiontests/i18n/tests.py
@@ -268,6 +268,7 @@ def test_l10n_enabled(self):
268 268
             self.assertEqual(u'66.666,666', localize(self.n))
269 269
             self.assertEqual(u'99.999,999', localize(self.f))
270 270
             self.assertEqual(u'10.000', localize(self.l))
  271
+            self.assertEqual(u'True', localize(True))
271 272
 
272 273
             settings.USE_THOUSAND_SEPARATOR = False
273 274
             self.assertEqual(u'66666,666', localize(self.n))

0 notes on commit ac91d5e

Please sign in to comment.
Something went wrong with that request. Please try again.