From 470f2d317e36cb6009496d08e1f016dc183dde29 Mon Sep 17 00:00:00 2001 From: Ali Emami <93864500+AliEmami81@users.noreply.github.com> Date: Tue, 13 Oct 2026 15:21:07 +0330 Subject: [PATCH] Fix Persian future-time translation and catalog language metadata --- .../locale/fa_IR/LC_MESSAGES/humanize.po | 8 +++---- tests/test_i18n.py | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/humanize/locale/fa_IR/LC_MESSAGES/humanize.po b/src/humanize/locale/fa_IR/LC_MESSAGES/humanize.po index a1ac7ac7..ca1ac1e6 100644 --- a/src/humanize/locale/fa_IR/LC_MESSAGES/humanize.po +++ b/src/humanize/locale/fa_IR/LC_MESSAGES/humanize.po @@ -1,4 +1,4 @@ -# German translation for humanize. +# Persian translation for humanize. # Copyright (C) 2016 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the humanize package. # Christian Klein , 2016. @@ -10,8 +10,8 @@ msgstr "" "POT-Creation-Date: 2023-01-08 19:22+0200\n" "PO-Revision-Date: 2017-01-10 02:44+0330\n" "Last-Translator: Christian Klein \n" -"Language-Team: German\n" -"Language: de\n" +"Language-Team: Persian\n" +"Language: fa_IR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -336,7 +336,7 @@ msgstr[1] "%d سال" #: src/humanize/time.py:256 #, python-format msgid "%s from now" -msgstr "%s تا به اکنون" +msgstr "%s دیگر" #: src/humanize/time.py:256 #, python-format diff --git a/tests/test_i18n.py b/tests/test_i18n.py index 683fe3ce..43e25a0a 100644 --- a/tests/test_i18n.py +++ b/tests/test_i18n.py @@ -102,6 +102,27 @@ def test_i18n() -> None: assert humanize.precisedelta(one_min_three_seconds) == "1 minute and 7 seconds" +@pytest.mark.parametrize( + "seconds, expected", + [ + (-60, "یک دقیقه پیش"), + (-3, "3 ثانیه پیش"), + (0, "اکنون"), + (3, "3 ثانیه دیگر"), + (60, "یک دقیقه دیگر"), + ], +) +def test_naturaltime_persian(seconds: int, expected: str) -> None: + try: + humanize.activate("fa_IR") + value = NOW + dt.timedelta(seconds=seconds) + assert humanize.naturaltime(value, when=NOW) == expected + except FileNotFoundError: + pytest.skip("Generate .mo with scripts/generate-translation-binaries.sh") + finally: + humanize.deactivate() + + def test_intcomma() -> None: number = 10_000_000