summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2019-06-09 12:48:20 -0700
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-06-11 20:34:59 +0200
commit9e38ed0536c7dc598a6c2c1bb774d0a8db3cdddc (patch)
tree735fc06110b76c86b0090a8dd53e2a6a1fcfae4e /docs/ref
parent175656e166712db019a4704c4031510b9fd6b00a (diff)
Fixed #27486 -- Fixed Python 3.7 DeprecationWarning in intword and filesizeformat filters.
intword and filesizeformat passed floats to ngettext() which is deprecated in Python 3.7. The rationale for this warning is documented in BPO-28692: https://bugs.python.org/issue28692. For filesizeformat, the filesize value is expected to be an int -- it fills %d string formatting placeholders. It was likely coerced to a float to ensure floating point division on Python 2. Python 3 always does floating point division, so coerce to an int instead of a float to fix the warning. For intword, the number may contain a decimal component. In English, a decimal component makes the noun plural. A helper function, round_away_from_one(), was added to convert the float to an integer that is appropriate for ngettext().
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/contrib/humanize.txt9
1 files changed, 8 insertions, 1 deletions
diff --git a/docs/ref/contrib/humanize.txt b/docs/ref/contrib/humanize.txt
index 9a30ce1aa4..edbdb136b0 100644
--- a/docs/ref/contrib/humanize.txt
+++ b/docs/ref/contrib/humanize.txt
@@ -57,7 +57,9 @@ e.g. with the ``'de'`` language:
===========
Converts a large integer (or a string representation of an integer) to a
-friendly text representation. Works best for numbers over 1 million.
+friendly text representation. Translates ``1.0`` as a singular phrase and all
+other numeric values as plural, this may be incorrect for some languages. Works
+best for numbers over 1 million.
Examples:
@@ -74,6 +76,11 @@ e.g. with the ``'de'`` language:
* ``1200000`` becomes ``'1,2 Millionen'``.
* ``1200000000`` becomes ``'1,2 Milliarden'``.
+.. versionchanged:: 3.0
+
+ All numeric values are now translated as plural, except ``1.0`` which is
+ translated as a singular phrase. This may be incorrect for some languages.
+
.. templatefilter:: naturalday
``naturalday``