Skip to content

Commit b5ba01b

Browse files
authored
Fix Persian future-time wording and locale metadata (#461)
1 parent 62aba2b commit b5ba01b

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# German translation for humanize.
1+
# Persian translation for humanize.
22
# Copyright (C) 2016 THE PACKAGE'S COPYRIGHT HOLDER
33
# This file is distributed under the same license as the humanize package.
44
# Christian Klein <chris@5711.org>, 2016.
@@ -10,8 +10,8 @@ msgstr ""
1010
"POT-Creation-Date: 2023-01-08 19:22+0200\n"
1111
"PO-Revision-Date: 2017-01-10 02:44+0330\n"
1212
"Last-Translator: Christian Klein <chris@5711.org>\n"
13-
"Language-Team: German\n"
14-
"Language: de\n"
13+
"Language-Team: Persian\n"
14+
"Language: fa_IR\n"
1515
"MIME-Version: 1.0\n"
1616
"Content-Type: text/plain; charset=utf-8\n"
1717
"Content-Transfer-Encoding: 8bit\n"
@@ -336,7 +336,7 @@ msgstr[1] "%d سال"
336336
#: src/humanize/time.py:256
337337
#, python-format
338338
msgid "%s from now"
339-
msgstr "%s تا به اکنون"
339+
msgstr "%s دیگر"
340340

341341
#: src/humanize/time.py:256
342342
#, python-format

‎tests/test_i18n.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,27 @@ def test_i18n() -> None:
106106
assert humanize.precisedelta(one_min_three_seconds) == "1 minute and 7 seconds"
107107

108108

109+
@pytest.mark.parametrize(
110+
"seconds, expected",
111+
[
112+
(-60, "یک دقیقه پیش"),
113+
(-3, "3 ثانیه پیش"),
114+
(0, "اکنون"),
115+
(3, "3 ثانیه دیگر"),
116+
(60, "یک دقیقه دیگر"),
117+
],
118+
)
119+
def test_naturaltime_persian(seconds: int, expected: str) -> None:
120+
try:
121+
humanize.activate("fa_IR")
122+
value = NOW + dt.timedelta(seconds=seconds)
123+
assert humanize.naturaltime(value, when=NOW) == expected
124+
except FileNotFoundError:
125+
pytest.skip("Generate .mo with scripts/generate-translation-binaries.sh")
126+
finally:
127+
humanize.deactivate()
128+
129+
109130
def test_intcomma() -> None:
110131
number = 10_000_000
111132

0 commit comments

Comments
 (0)