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
This commit is contained in:
parent
cf70c96ce0
commit
944ef3bb60
|
@ -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:
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -2,7 +2,7 @@ from django.conf import settings
|
|||
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:
|
||||
|
|
Loading…
Reference in New Issue