diff --git a/src/humanize/i18n.py b/src/humanize/i18n.py index 8422e9d6..2e653b2a 100644 --- a/src/humanize/i18n.py +++ b/src/humanize/i18n.py @@ -21,6 +21,7 @@ # Mapping of locale to thousands separator _THOUSANDS_SEPARATOR: dict[str | None, str] = { "de_DE": ".", + "es_ES": ".", "fr_FR": " ", "it_IT": ".", "pt_BR": ".", @@ -32,6 +33,7 @@ # Mapping of locale to decimal separator _DECIMAL_SEPARATOR: dict[str | None, str] = { "de_DE": ",", + "es_ES": ",", "fr_FR": ",", "it_IT": ",", "pt_BR": ",", diff --git a/tests/test_i18n.py b/tests/test_i18n.py index aa9655e6..b7e285c5 100644 --- a/tests/test_i18n.py +++ b/tests/test_i18n.py @@ -488,3 +488,15 @@ def test_intword_unit_has_no_format_placeholder(locale: str) -> None: pytest.skip("Generate .mo with tox -e compile-translations") finally: humanize.i18n.deactivate() + + +def test_spanish_numeric_separators(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setitem( + humanize.i18n._TRANSLATIONS, "es_ES", gettext.NullTranslations() + ) + try: + humanize.i18n.activate("es_ES") + assert humanize.intcomma(1234.5) == "1.234,5" + assert humanize.intcomma(1_234_567.25) == "1.234.567,25" + finally: + humanize.i18n.deactivate()