diff options
| author | Claude Paroz <claude@2xlibre.net> | 2018-07-19 22:44:40 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-07-19 16:44:40 -0400 |
| commit | 0adfba968e28cfb4e4d681e658866debbbd68089 (patch) | |
| tree | 929348b9e9b562b45deb0c8b7b748259f5e74471 /django/utils | |
| parent | 6b6bdfe25c946ee9512b3866d64930fe1be619fd (diff) | |
Fixed #29578 -- Made numberformat.format() honor forced l10n usage.
Thanks Sassan Haradji for the report.
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/formats.py | 3 | ||||
| -rw-r--r-- | django/utils/numberformat.py | 4 |
2 files changed, 4 insertions, 3 deletions
diff --git a/django/utils/formats.py b/django/utils/formats.py index bba45e3677..d5e5a555f6 100644 --- a/django/utils/formats.py +++ b/django/utils/formats.py @@ -179,7 +179,8 @@ def number_format(value, decimal_pos=None, use_l10n=None, force_grouping=False): decimal_pos, get_format('NUMBER_GROUPING', lang, use_l10n=use_l10n), get_format('THOUSAND_SEPARATOR', lang, use_l10n=use_l10n), - force_grouping=force_grouping + force_grouping=force_grouping, + use_l10n=use_l10n, ) diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py index 4dc37ae22b..9c0496342d 100644 --- a/django/utils/numberformat.py +++ b/django/utils/numberformat.py @@ -5,7 +5,7 @@ from django.utils.safestring import mark_safe def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='', - force_grouping=False): + force_grouping=False, use_l10n=None): """ Get a number (as a number or string), and return it as a string, using formats defined as arguments: @@ -18,7 +18,7 @@ def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='', module in locale.localeconv() LC_NUMERIC grouping (e.g. (3, 2, 0)). * thousand_sep: Thousand separator symbol (for example ",") """ - use_grouping = settings.USE_L10N and settings.USE_THOUSAND_SEPARATOR + use_grouping = (use_l10n or (use_l10n is None and settings.USE_L10N)) and settings.USE_THOUSAND_SEPARATOR use_grouping = use_grouping or force_grouping use_grouping = use_grouping and grouping != 0 # Make the common case fast |
