Browse files

[1.2.X] Fixed #14807 -- Ensure that boolean values aren't localized a…

…s T.rue and Fa.lse because of the thousand separator. Thanks to vanschelven for the report and

Backport of r14804 from trunk.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 70383cc commit 6c53a816e7fee8f21f6ed9c7fe1c151a65ea2a57 @freakboy3742 freakboy3742 committed Dec 4, 2010
Showing with 5 additions and 1 deletion.
  1. +4 −1 django/utils/
  2. +1 −0 tests/regressiontests/i18n/
5 django/utils/
@@ -6,6 +6,7 @@
from django.utils.importlib import import_module
from django.utils.encoding import smart_str
from django.utils import dateformat, numberformat, datetime_safe
+from django.utils.safestring import mark_safe
# format_cache is a mapping from (format_type, lang) to the format string.
# By using the cache, it is possible to avoid running get_format_modules
@@ -93,7 +94,9 @@ def localize(value):
Checks if value is a localizable type (date, number...) and returns it
formatted as a string using current locale format
- if isinstance(value, (decimal.Decimal, float, int, long)):
+ if isinstance(value, bool):
+ return mark_safe(unicode(value))
+ elif isinstance(value, (decimal.Decimal, float, int, long)):
return number_format(value)
elif isinstance(value, datetime.datetime):
return date_format(value, 'DATETIME_FORMAT')
1 tests/regressiontests/i18n/
@@ -250,6 +250,7 @@ def test_l10n_enabled(self):
self.assertEqual(u'66.666,666', localize(self.n))
self.assertEqual(u'99.999,999', localize(self.f))
self.assertEqual(u'10.000', localize(self.l))
+ self.assertEqual(u'True', localize(True))
self.assertEqual(u'66666,666', localize(self.n))

0 comments on commit 6c53a81

Please sign in to comment.