mirror of
https://github.com/django/django.git
synced 2025-05-01 20:54:38 +00:00
Fixed #32810 -- Optimized django.utils.formats.number_format() a bit.
Pre-calculate use_l10n for get_format() calls.
This commit is contained in:
parent
213850b4b9
commit
d6f3b58589
@ -171,10 +171,8 @@ def number_format(value, decimal_pos=None, use_l10n=None, force_grouping=False):
|
|||||||
If use_l10n is provided and is not None, it forces the value to
|
If use_l10n is provided and is not None, it forces the value to
|
||||||
be localized (or not), overriding the value of settings.USE_L10N.
|
be localized (or not), overriding the value of settings.USE_L10N.
|
||||||
"""
|
"""
|
||||||
if use_l10n or (use_l10n is None and settings.USE_L10N):
|
use_l10n = use_l10n or (use_l10n is None and settings.USE_L10N)
|
||||||
lang = get_language()
|
lang = get_language() if use_l10n else None
|
||||||
else:
|
|
||||||
lang = None
|
|
||||||
return numberformat.format(
|
return numberformat.format(
|
||||||
value,
|
value,
|
||||||
get_format('DECIMAL_SEPARATOR', lang, use_l10n=use_l10n),
|
get_format('DECIMAL_SEPARATOR', lang, use_l10n=use_l10n),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user