Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.2.X] Fixed #13702 -- Made sure to actually fall back to the l10n f…

…ormat strings provided in the settings, when disabled.

Backport from trunk (r13770).

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13771 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 3a6afc7e0b93ebc7dbe4060974dfc2d6e2973903 1 parent 686d6a4
Jannis Leidel authored September 12, 2010
4  django/conf/global_settings.py
@@ -370,8 +370,8 @@
370 370
 # Boolean that sets whether to add thousand separator when formatting numbers
371 371
 USE_THOUSAND_SEPARATOR = False
372 372
 
373  
-# Number of digits that will be togheter, when spliting them by THOUSAND_SEPARATOR
374  
-# 0 means no grouping, 3 means splitting by thousands...
  373
+# Number of digits that will be together, when spliting them by
  374
+# THOUSAND_SEPARATOR. 0 means no grouping, 3 means splitting by thousands...
375 375
 NUMBER_GROUPING = 0
376 376
 
377 377
 # Thousand separator symbol
20  django/utils/formats.py
@@ -79,16 +79,16 @@ def localize(value):
79 79
     Checks if value is a localizable type (date, number...) and returns it
80 80
     formatted as a string using current locale format
81 81
     """
82  
-    if settings.USE_L10N:
83  
-        if isinstance(value, (decimal.Decimal, float, int)):
84  
-            return number_format(value)
85  
-        elif isinstance(value, datetime.datetime):
86  
-            return date_format(value, 'DATETIME_FORMAT')
87  
-        elif isinstance(value, datetime.date):
88  
-            return date_format(value)
89  
-        elif isinstance(value, datetime.time):
90  
-            return time_format(value, 'TIME_FORMAT')
91  
-    return value
  82
+    if isinstance(value, (decimal.Decimal, float, int)):
  83
+        return number_format(value)
  84
+    elif isinstance(value, datetime.datetime):
  85
+        return date_format(value, 'DATETIME_FORMAT')
  86
+    elif isinstance(value, datetime.date):
  87
+        return date_format(value)
  88
+    elif isinstance(value, datetime.time):
  89
+        return time_format(value, 'TIME_FORMAT')
  90
+    else:
  91
+        return value
92 92
 
93 93
 def localize_input(value, default=None):
94 94
     """
12  tests/regressiontests/i18n/tests.py
@@ -170,14 +170,14 @@ def test_l10n_disabled(self):
170 170
             self.assertEqual(u'desembre 2009', date_format(self.d, 'YEAR_MONTH_FORMAT'))
171 171
             self.assertEqual(u'12/31/2009 8:50 p.m.', date_format(self.dt, 'SHORT_DATETIME_FORMAT'))
172 172
             self.assertEqual('No localizable', localize('No localizable'))
173  
-            self.assertEqual(decimal.Decimal('66666.666'), localize(self.n))
174  
-            self.assertEqual(99999.999, localize(self.f))
175  
-            self.assertEqual(datetime.date(2009, 12, 31), localize(self.d))
176  
-            self.assertEqual(datetime.datetime(2009, 12, 31, 20, 50), localize(self.dt))
  173
+            self.assertEqual('66666.666', localize(self.n))
  174
+            self.assertEqual('99999.999', localize(self.f))
  175
+            self.assertEqual(u'des. 31, 2009', localize(self.d))
  176
+            self.assertEqual(u'des. 31, 2009, 8:50 p.m.', localize(self.dt))
177 177
             self.assertEqual(u'66666.666', Template('{{ n }}').render(self.ctxt))
178 178
             self.assertEqual(u'99999.999', Template('{{ f }}').render(self.ctxt))
179  
-            self.assertEqual(u'2009-12-31', Template('{{ d }}').render(self.ctxt))
180  
-            self.assertEqual(u'2009-12-31 20:50:00', Template('{{ dt }}').render(self.ctxt))
  179
+            self.assertEqual(u'des. 31, 2009', Template('{{ d }}').render(self.ctxt))
  180
+            self.assertEqual(u'des. 31, 2009, 8:50 p.m.', Template('{{ dt }}').render(self.ctxt))
181 181
             self.assertEqual(u'66666.67', Template('{{ n|floatformat:2 }}').render(self.ctxt))
182 182
             self.assertEqual(u'100000.0', Template('{{ f|floatformat }}').render(self.ctxt))
183 183
             self.assertEqual(u'10:15 a.m.', Template('{{ t|time:"TIME_FORMAT" }}').render(self.ctxt))
2  tests/regressiontests/templates/filters.py
@@ -346,5 +346,5 @@ def get_filter_tests():
346 346
          'add04': (r'{{ i|add:"16" }}', {'i': 'not_an_int'}, 'not_an_int16'),
347 347
          'add05': (r'{{ l1|add:l2 }}', {'l1': [1, 2], 'l2': [3, 4]}, '[1, 2, 3, 4]'),
348 348
          'add06': (r'{{ t1|add:t2 }}', {'t1': (3, 4), 't2': (1, 2)}, '(3, 4, 1, 2)'),
349  
-         'add07': (r'{{ d|add:t }}', {'d': date(2000, 1, 1), 't': timedelta(10)}, '2000-01-11'),
  349
+         'add07': (r'{{ d|add:t }}', {'d': date(2000, 1, 1), 't': timedelta(10)}, 'Jan. 11, 2000'),
350 350
     }

0 notes on commit 3a6afc7

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