diff --git a/src/humanize/number.py b/src/humanize/number.py index 2ca7a69..77b79ab 100644 --- a/src/humanize/number.py +++ b/src/humanize/number.py @@ -261,7 +261,9 @@ def intword(value: NumberOrString, format: str = "%.1f") -> str: singular, plural = human_powers[ordinal] unit = _ngettext(singular, plural, math.ceil(rounded_value)) - return f"{negative_prefix}{format % rounded_value} {unit}" + decimal_sep = decimal_separator() + number = (format % rounded_value).replace(".", decimal_sep) + return f"{negative_prefix}{number} {unit}" def apnumber(value: NumberOrString) -> str: diff --git a/tests/test_i18n.py b/tests/test_i18n.py index 6c16c94..319a55d 100644 --- a/tests/test_i18n.py +++ b/tests/test_i18n.py @@ -91,6 +91,12 @@ def test_naturaldelta() -> None: @pytest.mark.parametrize( "locale, number, expected_result", [ + # Italian uses comma as decimal separator + ("it_IT", 1_000_000, "1,0 milione"), + ("it_IT", 1_200_000, "1,2 milioni"), + ("it_IT", 1_000_000_000, "1,0 miliardo"), + ("it_IT", 3_500_000_000, "3,5 miliardi"), + # Spanish uses dot as decimal separator ("es_ES", 1_000_000, "1.0 millón"), ("es_ES", 3_500_000, "3.5 millones"), ("es_ES", 1_000_000_000, "1.0 billón"),