Refs #32873 -- Avoided looking up settings._USE_L10N_INTERNAL twice.
This commit is contained in:
parent
7c318a8bdd
commit
7fd2deb3e8
|
@ -106,14 +106,11 @@ def get_format(format_type, lang=None, use_l10n=None):
|
||||||
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.
|
||||||
"""
|
"""
|
||||||
use_l10n = use_l10n or (
|
if use_l10n is None:
|
||||||
use_l10n is None
|
try:
|
||||||
and (
|
use_l10n = settings._USE_L10N_INTERNAL
|
||||||
settings._USE_L10N_INTERNAL
|
except AttributeError:
|
||||||
if hasattr(settings, "_USE_L10N_INTERNAL")
|
use_l10n = settings.USE_L10N
|
||||||
else settings.USE_L10N
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if use_l10n and lang is None:
|
if use_l10n and lang is None:
|
||||||
lang = get_language()
|
lang = get_language()
|
||||||
cache_key = (format_type, lang)
|
cache_key = (format_type, lang)
|
||||||
|
@ -181,14 +178,11 @@ 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.
|
||||||
"""
|
"""
|
||||||
use_l10n = use_l10n or (
|
if use_l10n is None:
|
||||||
use_l10n is None
|
try:
|
||||||
and (
|
use_l10n = settings._USE_L10N_INTERNAL
|
||||||
settings._USE_L10N_INTERNAL
|
except AttributeError:
|
||||||
if hasattr(settings, "_USE_L10N_INTERNAL")
|
use_l10n = settings.USE_L10N
|
||||||
else settings.USE_L10N
|
|
||||||
)
|
|
||||||
)
|
|
||||||
lang = get_language() if use_l10n else None
|
lang = get_language() if use_l10n else None
|
||||||
return numberformat.format(
|
return numberformat.format(
|
||||||
value,
|
value,
|
||||||
|
|
Loading…
Reference in New Issue