Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@jezdez jezdez authored
View
2  django/contrib/humanize/templatetags/humanize.py
@@ -41,7 +41,7 @@ def intcomma(value, use_l10n=True):
except (TypeError, ValueError):
return intcomma(value, False)
else:
- return number_format(value)
+ return number_format(value, force_grouping=True)
orig = force_unicode(value)
new = re.sub("^(-?\d+)(\d{3})", '\g<1>,\g<2>', orig)
if orig == new:
View
3  django/utils/formats.py
@@ -103,7 +103,7 @@ def time_format(value, format=None, use_l10n=None):
"""
return dateformat.time_format(value, get_format(format or 'TIME_FORMAT', use_l10n=use_l10n))
-def number_format(value, decimal_pos=None, use_l10n=None):
+def number_format(value, decimal_pos=None, use_l10n=None, force_grouping=False):
"""
Formats a numeric value using localization settings
@@ -120,6 +120,7 @@ def number_format(value, decimal_pos=None, use_l10n=None):
decimal_pos,
get_format('NUMBER_GROUPING', lang, use_l10n=use_l10n),
get_format('THOUSAND_SEPARATOR', lang, use_l10n=use_l10n),
+ force_grouping=force_grouping
)
def localize(value, use_l10n=None):
View
4 django/utils/numberformat.py
@@ -2,7 +2,7 @@
from django.utils.safestring import mark_safe
-def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep=''):
+def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='', force_grouping=False):
"""
Gets a number (as a number or string), and returns it as a string,
using formats definied as arguments:
@@ -13,7 +13,7 @@ def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep=''):
* thousand_sep: Thousand separator symbol (for example ",")
"""
- use_grouping = settings.USE_L10N and \
+ use_grouping = force_grouping or settings.USE_L10N and \
settings.USE_THOUSAND_SEPARATOR and grouping
# Make the common case fast:
if isinstance(number, int) and not use_grouping and not decimal_pos:

0 comments on commit 944ef3b

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