Skip to content

Commit

Permalink
Fixed #16404 -- Fixed a regression in the localization changes in the…
Browse files Browse the repository at this point in the history
… 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
jezdez committed Sep 8, 2011
1 parent cf70c96 commit 944ef3b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion django/contrib/humanize/templatetags/humanize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion django/utils/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions django/utils/numberformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 944ef3b

Please sign in to comment.