Skip to content

Commit cd7996a

Browse files
committed
Complete missing Simplified Chinese translations
1 parent a2006ea commit cd7996a

2 files changed

Lines changed: 42 additions & 6 deletions

File tree

‎src/humanize/locale/zh_CN/LC_MESSAGES/humanize.po‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ msgstr[1] "古高尔"
192192

193193
#: src/humanize/number.py:301
194194
msgid "zero"
195-
msgstr ""
195+
msgstr "零"
196196

197197
#: src/humanize/number.py:302
198198
msgid "one"
@@ -234,15 +234,15 @@ msgstr "九"
234234
#, python-format
235235
msgid "%d microsecond"
236236
msgid_plural "%d microseconds"
237-
msgstr[0] ""
238-
msgstr[1] ""
237+
msgstr[0] "%d微秒"
238+
msgstr[1] "%d微秒"
239239

240240
#: src/humanize/time.py:161
241241
#, python-format
242242
msgid "%d millisecond"
243243
msgid_plural "%d milliseconds"
244-
msgstr[0] ""
245-
msgstr[1] ""
244+
msgstr[0] "%d毫秒"
245+
msgstr[1] "%d毫秒"
246246

247247
#: src/humanize/time.py:164 src/humanize/time.py:259
248248
msgid "a moment"
@@ -361,4 +361,4 @@ msgstr "昨天"
361361
#: src/humanize/time.py:600
362362
#, python-format
363363
msgid "%s and %s"
364-
msgstr ""
364+
msgstr "%s和%s"

‎tests/test_i18n.py‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,42 @@ def test_naturaltime_persian(seconds: int, expected: str) -> None:
127127
humanize.deactivate()
128128

129129

130+
@pytest.mark.parametrize(
131+
"microseconds, minimum_unit, expected",
132+
[
133+
(1, "microseconds", "1微秒"),
134+
(2, "microseconds", "2微秒"),
135+
(1000, "milliseconds", "1毫秒"),
136+
(2000, "milliseconds", "2毫秒"),
137+
],
138+
)
139+
def test_naturaldelta_chinese_subseconds(
140+
microseconds: int, minimum_unit: str, expected: str
141+
) -> None:
142+
try:
143+
humanize.activate("zh_CN")
144+
value = dt.timedelta(microseconds=microseconds)
145+
assert humanize.naturaldelta(value, minimum_unit=minimum_unit) == expected
146+
except FileNotFoundError:
147+
pytest.skip("Generate .mo with scripts/generate-translation-binaries.sh")
148+
finally:
149+
humanize.deactivate()
150+
151+
152+
def test_chinese_zero_and_duration_conjunction() -> None:
153+
try:
154+
humanize.activate("zh_CN")
155+
assert humanize.apnumber(0) == "零"
156+
assert humanize.precisedelta(61) == "1分和1秒"
157+
value = dt.timedelta(microseconds=1002)
158+
result = humanize.precisedelta(value, minimum_unit="microseconds")
159+
assert result == "1毫秒和2微秒"
160+
except FileNotFoundError:
161+
pytest.skip("Generate .mo with scripts/generate-translation-binaries.sh")
162+
finally:
163+
humanize.deactivate()
164+
165+
130166
def test_intcomma() -> None:
131167
number = 10_000_000
132168

0 commit comments

Comments
 (0)