summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2023-01-06 14:46:33 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-01-17 11:49:15 +0100
commit8d98f99a4ab5de6f2c730399f53eba8bf6bea470 (patch)
treec9c643c4c77b0d5fb014270f62ba2ca193befc8a /django/utils
parent0be8095b254fad65b2480d677ebe6098c41bbad6 (diff)
Refs #32873 -- Removed settings.USE_L10N per deprecation timeline.
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/formats.py20
-rw-r--r--django/utils/numberformat.py6
2 files changed, 10 insertions, 16 deletions
diff --git a/django/utils/formats.py b/django/utils/formats.py
index 85d24b9443..ba8c97c233 100644
--- a/django/utils/formats.py
+++ b/django/utils/formats.py
@@ -104,13 +104,10 @@ def get_format(format_type, lang=None, use_l10n=None):
format_type is the name of the format, e.g. 'DATE_FORMAT'.
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), otherwise it's always localized.
"""
if use_l10n is None:
- try:
- use_l10n = settings._USE_L10N_INTERNAL
- except AttributeError:
- use_l10n = settings.USE_L10N
+ use_l10n = True
if use_l10n and lang is None:
lang = get_language()
format_type = str(format_type) # format_type may be lazy.
@@ -153,7 +150,7 @@ def date_format(value, format=None, use_l10n=None):
localizable format.
If use_l10n is provided and is not None, that will force the value to
- be localized (or not), overriding the value of settings.USE_L10N.
+ be localized (or not), otherwise it's always localized.
"""
return dateformat.format(
value, get_format(format or "DATE_FORMAT", use_l10n=use_l10n)
@@ -165,7 +162,7 @@ def time_format(value, format=None, use_l10n=None):
Format a datetime.time object using a localizable format.
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), otherwise it's always localized.
"""
return dateformat.time_format(
value, get_format(format or "TIME_FORMAT", use_l10n=use_l10n)
@@ -177,13 +174,10 @@ def number_format(value, decimal_pos=None, use_l10n=None, force_grouping=False):
Format a numeric value using localization settings.
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), otherwise it's always localized.
"""
if use_l10n is None:
- try:
- use_l10n = settings._USE_L10N_INTERNAL
- except AttributeError:
- use_l10n = settings.USE_L10N
+ use_l10n = True
lang = get_language() if use_l10n else None
return numberformat.format(
value,
@@ -202,7 +196,7 @@ def localize(value, use_l10n=None):
formatted as a string using current locale format.
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), otherwise it's always localized.
"""
if isinstance(value, str): # Handle strings first for performance reasons.
return value
diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py
index a1ecd1bd0d..43c420d2fb 100644
--- a/django/utils/numberformat.py
+++ b/django/utils/numberformat.py
@@ -27,9 +27,9 @@ def format(
"""
if number is None or number == "":
return mark_safe(number)
- use_grouping = (
- use_l10n or (use_l10n is None and settings.USE_L10N)
- ) and settings.USE_THOUSAND_SEPARATOR
+ if use_l10n is None:
+ use_l10n = True
+ use_grouping = 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