diff --git a/src/humanize/locale/zh_CN/LC_MESSAGES/humanize.po b/src/humanize/locale/zh_CN/LC_MESSAGES/humanize.po index 52d718d6..8efa98cb 100644 --- a/src/humanize/locale/zh_CN/LC_MESSAGES/humanize.po +++ b/src/humanize/locale/zh_CN/LC_MESSAGES/humanize.po @@ -192,7 +192,7 @@ msgstr[1] "古高尔" #: src/humanize/number.py:301 msgid "zero" -msgstr "" +msgstr "零" #: src/humanize/number.py:302 msgid "one" @@ -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" @@ -361,4 +361,4 @@ msgstr "昨天" #: src/humanize/time.py:600 #, python-format msgid "%s and %s" -msgstr "" +msgstr "%s和%s" diff --git a/tests/test_i18n.py b/tests/test_i18n.py index 0d3ced84..c69953b4 100644 --- a/tests/test_i18n.py +++ b/tests/test_i18n.py @@ -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