From ac794ec1dfbdbd4bc096ea153af89a87ac66d825 Mon Sep 17 00:00:00 2001 From: adityajai119 Date: Mon, 30 Nov 2026 13:31:18 +0530 Subject: [PATCH 1/2] Add Spanish numeric separators to i18n locale map --- src/humanize/i18n.py | 2 ++ tests/test_i18n.py | 11 +++++++++++ 2 files changed, 13 insertions(+) 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..cf1fba62 100644 --- a/tests/test_i18n.py +++ b/tests/test_i18n.py @@ -488,3 +488,14 @@ 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() From f5dc5b2c9bb88d0b5bff97e6be5073fbb1f9f701 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Nov 2026 08:02:48 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_i18n.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_i18n.py b/tests/test_i18n.py index cf1fba62..b7e285c5 100644 --- a/tests/test_i18n.py +++ b/tests/test_i18n.py @@ -489,6 +489,7 @@ def test_intword_unit_has_no_format_placeholder(locale: str) -> None: finally: humanize.i18n.deactivate() + def test_spanish_numeric_separators(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setitem( humanize.i18n._TRANSLATIONS, "es_ES", gettext.NullTranslations()