Skip to content
Open
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
12 changes: 6 additions & 6 deletions src/humanize/locale/zh_CN/LC_MESSAGES/humanize.po
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ msgstr[1] "古高尔"

#: src/humanize/number.py:301
msgid "zero"
msgstr ""
msgstr "零"

#: src/humanize/number.py:302
msgid "one"
Expand Down Expand Up @@ -234,15 +234,15 @@ msgstr "九"
#, python-format
msgid "%d microsecond"
msgid_plural "%d microseconds"
msgstr[0] ""
msgstr[1] ""
msgstr[0] "%d微秒"
msgstr[1] "%d微秒"

#: src/humanize/time.py:161
#, python-format
msgid "%d millisecond"
msgid_plural "%d milliseconds"
msgstr[0] ""
msgstr[1] ""
msgstr[0] "%d毫秒"
msgstr[1] "%d毫秒"

#: src/humanize/time.py:164 src/humanize/time.py:259
msgid "a moment"
Expand Down Expand Up @@ -361,4 +361,4 @@ msgstr "昨天"
#: src/humanize/time.py:600
#, python-format
msgid "%s and %s"
msgstr ""
msgstr "%s和%s"
36 changes: 36 additions & 0 deletions tests/test_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,42 @@ def test_naturaltime_persian(seconds: int, expected: str) -> None:
humanize.deactivate()


@pytest.mark.parametrize(
"microseconds, minimum_unit, expected",
[
(1, "microseconds", "1微秒"),
(2, "microseconds", "2微秒"),
(1000, "milliseconds", "1毫秒"),
(2000, "milliseconds", "2毫秒"),
],
)
def test_naturaldelta_chinese_subseconds(
microseconds: int, minimum_unit: str, expected: str
) -> None:
try:
humanize.activate("zh_CN")
value = dt.timedelta(microseconds=microseconds)
assert humanize.naturaldelta(value, minimum_unit=minimum_unit) == expected
except FileNotFoundError:
pytest.skip("Generate .mo with scripts/generate-translation-binaries.sh")
finally:
humanize.deactivate()


def test_chinese_zero_and_duration_conjunction() -> None:
try:
humanize.activate("zh_CN")
assert humanize.apnumber(0) == "零"
assert humanize.precisedelta(61) == "1分和1秒"
value = dt.timedelta(microseconds=1002)
result = humanize.precisedelta(value, minimum_unit="microseconds")
assert result == "1毫秒和2微秒"
except FileNotFoundError:
pytest.skip("Generate .mo with scripts/generate-translation-binaries.sh")
finally:
humanize.deactivate()


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

Expand Down
Loading