Fixed #30086, Refs #32873 -- Made floatformat template filter independent of USE_L10N.

This commit is contained in:
Mariusz Felisiak 2021-09-08 08:37:27 +02:00 committed by GitHub
parent 301a85a12f
commit 4a43335d30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 79 additions and 21 deletions

View file

@ -1736,6 +1736,18 @@ example, when the active locale is ``en`` (English):
``34232.00`` ``{{ value|floatformat:"-3g" }}`` ``34,232``
============ ================================= =============
Output is always localized (independently of the :ttag:`{% localize off %}
<localize>` tag) unless the argument passed to ``floatformat`` has the ``u``
suffix, which will force disabling localization. For example, when the active
locale is ``pl`` (Polish):
============ ================================= =============
``value`` Template Output
============ ================================= =============
``34.23234`` ``{{ value|floatformat:"3" }}`` ``34,232``
``34.23234`` ``{{ value|floatformat:"3u" }}`` ``34.232``
============ ================================= =============
Using ``floatformat`` with no argument is equivalent to using ``floatformat``
with an argument of ``-1``.
@ -1743,6 +1755,13 @@ with an argument of ``-1``.
The ``g`` suffix to force grouping by thousand separators was added.
.. versionchanged:: 4.0
``floatformat`` template filter no longer depends on the
:setting:`USE_L10N` setting and always returns localized output.
The ``u`` suffix to force disabling localization was added.
.. templatefilter:: force_escape
``force_escape``