Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #16404 -- Fixed a regression in the localization changes in the…

… humanize app made in r16168. Thanks, grepsd@gmail.com.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16726 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 944ef3bb60eae989aa7d536e509f9cc80be0adcb 1 parent cf70c96
Jannis Leidel authored September 08, 2011
2  django/contrib/humanize/templatetags/humanize.py
@@ -41,7 +41,7 @@ def intcomma(value, use_l10n=True):
41 41
         except (TypeError, ValueError):
42 42
             return intcomma(value, False)
43 43
         else:
44  
-            return number_format(value)
  44
+            return number_format(value, force_grouping=True)
45 45
     orig = force_unicode(value)
46 46
     new = re.sub("^(-?\d+)(\d{3})", '\g<1>,\g<2>', orig)
47 47
     if orig == new:
3  django/utils/formats.py
@@ -103,7 +103,7 @@ def time_format(value, format=None, use_l10n=None):
103 103
     """
104 104
     return dateformat.time_format(value, get_format(format or 'TIME_FORMAT', use_l10n=use_l10n))
105 105
 
106  
-def number_format(value, decimal_pos=None, use_l10n=None):
  106
+def number_format(value, decimal_pos=None, use_l10n=None, force_grouping=False):
107 107
     """
108 108
     Formats a numeric value using localization settings
109 109
 
@@ -120,6 +120,7 @@ def number_format(value, decimal_pos=None, use_l10n=None):
120 120
         decimal_pos,
121 121
         get_format('NUMBER_GROUPING', lang, use_l10n=use_l10n),
122 122
         get_format('THOUSAND_SEPARATOR', lang, use_l10n=use_l10n),
  123
+        force_grouping=force_grouping
123 124
     )
124 125
 
125 126
 def localize(value, use_l10n=None):
4  django/utils/numberformat.py
@@ -2,7 +2,7 @@
2 2
 from django.utils.safestring import mark_safe
3 3
 
4 4
 
5  
-def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep=''):
  5
+def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='', force_grouping=False):
6 6
     """
7 7
     Gets a number (as a number or string), and returns it as a string,
8 8
     using formats definied as arguments:
@@ -13,7 +13,7 @@ def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep=''):
13 13
     * thousand_sep: Thousand separator symbol (for example ",")
14 14
 
15 15
     """
16  
-    use_grouping = settings.USE_L10N and \
  16
+    use_grouping = force_grouping or settings.USE_L10N and \
17 17
         settings.USE_THOUSAND_SEPARATOR and grouping
18 18
     # Make the common case fast:
19 19
     if isinstance(number, int) and not use_grouping and not decimal_pos:

0 notes on commit 944ef3b

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