Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/humanize/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": ".",
Expand All @@ -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": ",",
Expand Down
12 changes: 12 additions & 0 deletions tests/test_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()