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
3 changes: 3 additions & 0 deletions src/humanize/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def activate(
Raises:
Exception: If humanize cannot find the locale folder.
"""
if locale == "en_GB" or locale == "en_US":
locale = None

if path is None:
path = _get_default_locale_path()

Expand Down
15 changes: 15 additions & 0 deletions tests/test_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ def test_i18n() -> None:
assert humanize.precisedelta(one_min_three_seconds) == "1 minute and 7 seconds"


def test_en_locale() -> None:
three_seconds = NOW - dt.timedelta(seconds=3)

humanize.i18n.activate(None)
test_str = humanize.naturaltime(three_seconds)

humanize.i18n.activate("en_US")
assert test_str == humanize.naturaltime(three_seconds)

humanize.i18n.activate("en_GB")
assert test_str == humanize.naturaltime(three_seconds)

humanize.i18n.deactivate()


def test_intcomma() -> None:
number = 10_000_000

Expand Down
Loading