Skip to content

Handle en_GB and en_US in i18n #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
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