diff --git a/django/conf/locale/cs/LC_MESSAGES/django.mo b/django/conf/locale/cs/LC_MESSAGES/django.mo index 121d7d4a2b..addcb5054d 100644 Binary files a/django/conf/locale/cs/LC_MESSAGES/django.mo and b/django/conf/locale/cs/LC_MESSAGES/django.mo differ diff --git a/django/conf/locale/cs/LC_MESSAGES/django.po b/django/conf/locale/cs/LC_MESSAGES/django.po index 33c32e194b..bf2afb981f 100644 --- a/django/conf/locale/cs/LC_MESSAGES/django.po +++ b/django/conf/locale/cs/LC_MESSAGES/django.po @@ -13,7 +13,7 @@ msgid "" msgstr "" "Project-Id-Version: django\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-01-15 09:00+0100\n" +"POT-Creation-Date: 2021-04-10 16:05+0200\n" "PO-Revision-Date: 2021-03-18 23:20+0000\n" "Last-Translator: Vláďa Macek \n" "Language-Team: Czech (http://www.transifex.com/django/django/language/cs/)\n" @@ -1143,52 +1143,52 @@ msgid ", " msgstr ", " #, python-format -msgid "%d year" -msgid_plural "%d years" -msgstr[0] "%d rok" -msgstr[1] "%d roky" -msgstr[2] "%d roku" -msgstr[3] "%d let" +msgid "%(num)d year" +msgid_plural "%(num)d years" +msgstr[0] "%(num)d rok" +msgstr[1] "%(num)d roky" +msgstr[2] "%(num)d roku" +msgstr[3] "%(num)d let" #, python-format -msgid "%d month" -msgid_plural "%d months" -msgstr[0] "%d měsíc" -msgstr[1] "%d měsíce" -msgstr[2] "%d měsíců" -msgstr[3] "%d měsíců" +msgid "%(num)d month" +msgid_plural "%(num)d months" +msgstr[0] "%(num)d měsíc" +msgstr[1] "%(num)d měsíce" +msgstr[2] "%(num)d měsíců" +msgstr[3] "%(num)d měsíců" #, python-format -msgid "%d week" -msgid_plural "%d weeks" -msgstr[0] "%d týden" -msgstr[1] "%d týdny" -msgstr[2] "%d týdne" -msgstr[3] "%d týdnů" +msgid "%(num)d week" +msgid_plural "%(num)d weeks" +msgstr[0] "%(num)d týden" +msgstr[1] "%(num)d týdny" +msgstr[2] "%(num)d týdne" +msgstr[3] "%(num)d týdnů" #, python-format -msgid "%d day" -msgid_plural "%d days" -msgstr[0] "%d den" -msgstr[1] "%d dny" -msgstr[2] "%d dní" -msgstr[3] "%d dní" +msgid "%(num)d day" +msgid_plural "%(num)d days" +msgstr[0] "%(num)d den" +msgstr[1] "%(num)d dny" +msgstr[2] "%(num)d dní" +msgstr[3] "%(num)d dní" #, python-format -msgid "%d hour" -msgid_plural "%d hours" -msgstr[0] "%d hodina" -msgstr[1] "%d hodiny" -msgstr[2] "%d hodiny" -msgstr[3] "%d hodin" +msgid "%(num)d hour" +msgid_plural "%(num)d hours" +msgstr[0] "%(num)d hodina" +msgstr[1] "%(num)d hodiny" +msgstr[2] "%(num)d hodiny" +msgstr[3] "%(num)d hodin" #, python-format -msgid "%d minute" -msgid_plural "%d minutes" -msgstr[0] "%d minuta" -msgstr[1] "%d minuty" -msgstr[2] "%d minut" -msgstr[3] "%d minut" +msgid "%(num)d minute" +msgid_plural "%(num)d minutes" +msgstr[0] "%(num)d minuta" +msgstr[1] "%(num)d minuty" +msgstr[2] "%(num)d minut" +msgstr[3] "%(num)d minut" msgid "Forbidden" msgstr "Nepřístupné (Forbidden)" diff --git a/django/conf/locale/en/LC_MESSAGES/django.po b/django/conf/locale/en/LC_MESSAGES/django.po index e3d7690c86..5a96b740c7 100644 --- a/django/conf/locale/en/LC_MESSAGES/django.po +++ b/django/conf/locale/en/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: Django\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-01-15 09:00+0100\n" +"POT-Creation-Date: 2021-04-10 16:05+0200\n" "PO-Revision-Date: 2010-05-13 15:35+0200\n" "Last-Translator: Django team\n" "Language-Team: English \n" @@ -1364,43 +1364,43 @@ msgstr "" #: utils/timesince.py:9 #, python-format -msgid "%d year" -msgid_plural "%d years" +msgid "%(num)d year" +msgid_plural "%(num)d years" msgstr[0] "" msgstr[1] "" #: utils/timesince.py:10 #, python-format -msgid "%d month" -msgid_plural "%d months" +msgid "%(num)d month" +msgid_plural "%(num)d months" msgstr[0] "" msgstr[1] "" #: utils/timesince.py:11 #, python-format -msgid "%d week" -msgid_plural "%d weeks" +msgid "%(num)d week" +msgid_plural "%(num)d weeks" msgstr[0] "" msgstr[1] "" #: utils/timesince.py:12 #, python-format -msgid "%d day" -msgid_plural "%d days" +msgid "%(num)d day" +msgid_plural "%(num)d days" msgstr[0] "" msgstr[1] "" #: utils/timesince.py:13 #, python-format -msgid "%d hour" -msgid_plural "%d hours" +msgid "%(num)d hour" +msgid_plural "%(num)d hours" msgstr[0] "" msgstr[1] "" #: utils/timesince.py:14 #, python-format -msgid "%d minute" -msgid_plural "%d minutes" +msgid "%(num)d minute" +msgid_plural "%(num)d minutes" msgstr[0] "" msgstr[1] "" diff --git a/django/contrib/humanize/locale/cs/LC_MESSAGES/django.mo b/django/contrib/humanize/locale/cs/LC_MESSAGES/django.mo index 4951d85b71..4b4622290b 100644 Binary files a/django/contrib/humanize/locale/cs/LC_MESSAGES/django.mo and b/django/contrib/humanize/locale/cs/LC_MESSAGES/django.mo differ diff --git a/django/contrib/humanize/locale/cs/LC_MESSAGES/django.po b/django/contrib/humanize/locale/cs/LC_MESSAGES/django.po index 679569c0f9..f61b7e5192 100644 --- a/django/contrib/humanize/locale/cs/LC_MESSAGES/django.po +++ b/django/contrib/humanize/locale/cs/LC_MESSAGES/django.po @@ -279,110 +279,110 @@ msgstr "za %(delta)s" #. Translators: 'naturaltime-past' strings will be included in '%(delta)s ago' #, python-format msgctxt "naturaltime-past" -msgid "%d year" -msgid_plural "%d years" -msgstr[0] "%d rokem" -msgstr[1] "%d lety" -msgstr[2] "%d rokem" -msgstr[3] "%d lety" +msgid "%(num)d year" +msgid_plural "%(num)d years" +msgstr[0] "%(num)d rokem" +msgstr[1] "%(num)d lety" +msgstr[2] "%(num)d rokem" +msgstr[3] "%(num)d lety" #, python-format msgctxt "naturaltime-past" -msgid "%d month" -msgid_plural "%d months" -msgstr[0] "%d měsícem" -msgstr[1] "%d měsíci" -msgstr[2] "%d měsícem" -msgstr[3] "%d měsíci" +msgid "%(num)d month" +msgid_plural "%(num)d months" +msgstr[0] "%(num)d měsícem" +msgstr[1] "%(num)d měsíci" +msgstr[2] "%(num)d měsícem" +msgstr[3] "%(num)d měsíci" #, python-format msgctxt "naturaltime-past" -msgid "%d week" -msgid_plural "%d weeks" -msgstr[0] "%d týdnem" -msgstr[1] "%d týdny" -msgstr[2] "%d týdny" -msgstr[3] "%d týdny" +msgid "%(num)d week" +msgid_plural "%(num)d weeks" +msgstr[0] "%(num)d týdnem" +msgstr[1] "%(num)d týdny" +msgstr[2] "%(num)d týdny" +msgstr[3] "%(num)d týdny" #, python-format msgctxt "naturaltime-past" -msgid "%d day" -msgid_plural "%d days" -msgstr[0] "%d dnem" -msgstr[1] "%d dny" -msgstr[2] "%d dny" -msgstr[3] "%d dny" +msgid "%(num)d day" +msgid_plural "%(num)d days" +msgstr[0] "%(num)d dnem" +msgstr[1] "%(num)d dny" +msgstr[2] "%(num)d dny" +msgstr[3] "%(num)d dny" #, python-format msgctxt "naturaltime-past" -msgid "%d hour" -msgid_plural "%d hours" -msgstr[0] "%d hodinou" -msgstr[1] "%d hodinami" -msgstr[2] "%d hodinami" -msgstr[3] "%d hodinami" +msgid "%(num)d hour" +msgid_plural "%(num)d hours" +msgstr[0] "%(num)d hodinou" +msgstr[1] "%(num)d hodinami" +msgstr[2] "%(num)d hodinami" +msgstr[3] "%(num)d hodinami" #, python-format msgctxt "naturaltime-past" -msgid "%d minute" -msgid_plural "%d minutes" -msgstr[0] "%d minutou" -msgstr[1] "%d minutami" -msgstr[2] "%d minutami" -msgstr[3] "%d minutami" +msgid "%(num)d minute" +msgid_plural "%(num)d minutes" +msgstr[0] "%(num)d minutou" +msgstr[1] "%(num)d minutami" +msgstr[2] "%(num)d minutami" +msgstr[3] "%(num)d minutami" #. Translators: 'naturaltime-future' strings will be included in '%(delta)s #. from now' #, python-format msgctxt "naturaltime-future" -msgid "%d year" -msgid_plural "%d years" -msgstr[0] "%d rok" -msgstr[1] "%d roky" -msgstr[2] "%d let" -msgstr[3] "%d let" +msgid "%(num)d year" +msgid_plural "%(num)d years" +msgstr[0] "%(num)d rok" +msgstr[1] "%(num)d roky" +msgstr[2] "%(num)d let" +msgstr[3] "%(num)d let" #, python-format msgctxt "naturaltime-future" -msgid "%d month" -msgid_plural "%d months" -msgstr[0] "%d měsíc" -msgstr[1] "%d měsíce" -msgstr[2] "%d měsíců" -msgstr[3] "%d měsíců" +msgid "%(num)d month" +msgid_plural "%(num)d months" +msgstr[0] "%(num)d měsíc" +msgstr[1] "%(num)d měsíce" +msgstr[2] "%(num)d měsíců" +msgstr[3] "%(num)d měsíců" #, python-format msgctxt "naturaltime-future" -msgid "%d week" -msgid_plural "%d weeks" -msgstr[0] "%d týden" -msgstr[1] "%d týdny" -msgstr[2] "%d týdnů" -msgstr[3] "%d týdnů" +msgid "%(num)d week" +msgid_plural "%(num)d weeks" +msgstr[0] "%(num)d týden" +msgstr[1] "%(num)d týdny" +msgstr[2] "%(num)d týdnů" +msgstr[3] "%(num)d týdnů" #, python-format msgctxt "naturaltime-future" -msgid "%d day" -msgid_plural "%d days" -msgstr[0] "%d den" -msgstr[1] "%d dny" -msgstr[2] "%d dní" -msgstr[3] "%d dní" +msgid "%(num)d day" +msgid_plural "%(num)d days" +msgstr[0] "%(num)d den" +msgstr[1] "%(num)d dny" +msgstr[2] "%(num)d dní" +msgstr[3] "%(num)d dní" #, python-format msgctxt "naturaltime-future" -msgid "%d hour" -msgid_plural "%d hours" -msgstr[0] "%d hodina" -msgstr[1] "%d hodiny" -msgstr[2] "%d hodin" -msgstr[3] "%d hodin" +msgid "%(num)d hour" +msgid_plural "%(num)d hours" +msgstr[0] "%(num)d hodina" +msgstr[1] "%(num)d hodiny" +msgstr[2] "%(num)d hodin" +msgstr[3] "%(num)d hodin" #, python-format msgctxt "naturaltime-future" -msgid "%d minute" -msgid_plural "%d minutes" -msgstr[0] "%d minuta" -msgstr[1] "%d minuty" -msgstr[2] "%d minut" -msgstr[3] "%d minut" +msgid "%(num)d minute" +msgid_plural "%(num)d minutes" +msgstr[0] "%(num)d minuta" +msgstr[1] "%(num)d minuty" +msgstr[2] "%(num)d minut" +msgstr[3] "%(num)d minut" diff --git a/django/contrib/humanize/locale/en/LC_MESSAGES/django.po b/django/contrib/humanize/locale/en/LC_MESSAGES/django.po index 88f8982ecc..cf9ec2fcb7 100644 --- a/django/contrib/humanize/locale/en/LC_MESSAGES/django.po +++ b/django/contrib/humanize/locale/en/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: Django\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-01-15 09:00+0100\n" +"POT-Creation-Date: 2021-04-07 14:40+0200\n" "PO-Revision-Date: 2010-05-13 15:35+0200\n" "Last-Translator: Django team\n" "Language-Team: English \n" @@ -283,48 +283,48 @@ msgstr "" #: contrib/humanize/templatetags/humanize.py:205 #, python-format msgctxt "naturaltime-past" -msgid "%d year" -msgid_plural "%d years" +msgid "%(num)d year" +msgid_plural "%(num)d years" msgstr[0] "" msgstr[1] "" #: contrib/humanize/templatetags/humanize.py:206 #, python-format msgctxt "naturaltime-past" -msgid "%d month" -msgid_plural "%d months" +msgid "%(num)d month" +msgid_plural "%(num)d months" msgstr[0] "" msgstr[1] "" #: contrib/humanize/templatetags/humanize.py:207 #, python-format msgctxt "naturaltime-past" -msgid "%d week" -msgid_plural "%d weeks" +msgid "%(num)d week" +msgid_plural "%(num)d weeks" msgstr[0] "" msgstr[1] "" #: contrib/humanize/templatetags/humanize.py:208 #, python-format msgctxt "naturaltime-past" -msgid "%d day" -msgid_plural "%d days" +msgid "%(num)d day" +msgid_plural "%(num)d days" msgstr[0] "" msgstr[1] "" #: contrib/humanize/templatetags/humanize.py:209 #, python-format msgctxt "naturaltime-past" -msgid "%d hour" -msgid_plural "%d hours" +msgid "%(num)d hour" +msgid_plural "%(num)d hours" msgstr[0] "" msgstr[1] "" #: contrib/humanize/templatetags/humanize.py:210 #, python-format msgctxt "naturaltime-past" -msgid "%d minute" -msgid_plural "%d minutes" +msgid "%(num)d minute" +msgid_plural "%(num)d minutes" msgstr[0] "" msgstr[1] "" @@ -332,47 +332,47 @@ msgstr[1] "" #: contrib/humanize/templatetags/humanize.py:214 #, python-format msgctxt "naturaltime-future" -msgid "%d year" -msgid_plural "%d years" +msgid "%(num)d year" +msgid_plural "%(num)d years" msgstr[0] "" msgstr[1] "" #: contrib/humanize/templatetags/humanize.py:215 #, python-format msgctxt "naturaltime-future" -msgid "%d month" -msgid_plural "%d months" +msgid "%(num)d month" +msgid_plural "%(num)d months" msgstr[0] "" msgstr[1] "" #: contrib/humanize/templatetags/humanize.py:216 #, python-format msgctxt "naturaltime-future" -msgid "%d week" -msgid_plural "%d weeks" +msgid "%(num)d week" +msgid_plural "%(num)d weeks" msgstr[0] "" msgstr[1] "" #: contrib/humanize/templatetags/humanize.py:217 #, python-format msgctxt "naturaltime-future" -msgid "%d day" -msgid_plural "%d days" +msgid "%(num)d day" +msgid_plural "%(num)d days" msgstr[0] "" msgstr[1] "" #: contrib/humanize/templatetags/humanize.py:218 #, python-format msgctxt "naturaltime-future" -msgid "%d hour" -msgid_plural "%d hours" +msgid "%(num)d hour" +msgid_plural "%(num)d hours" msgstr[0] "" msgstr[1] "" #: contrib/humanize/templatetags/humanize.py:219 #, python-format msgctxt "naturaltime-future" -msgid "%d minute" -msgid_plural "%d minutes" +msgid "%(num)d minute" +msgid_plural "%(num)d minutes" msgstr[0] "" msgstr[1] "" diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py index 753a0d9fe1..095a053fa1 100644 --- a/django/contrib/humanize/templatetags/humanize.py +++ b/django/contrib/humanize/templatetags/humanize.py @@ -202,21 +202,21 @@ class NaturalTimeFormatter: } past_substrings = { # Translators: 'naturaltime-past' strings will be included in '%(delta)s ago' - 'year': npgettext_lazy('naturaltime-past', '%d year', '%d years'), - 'month': npgettext_lazy('naturaltime-past', '%d month', '%d months'), - 'week': npgettext_lazy('naturaltime-past', '%d week', '%d weeks'), - 'day': npgettext_lazy('naturaltime-past', '%d day', '%d days'), - 'hour': npgettext_lazy('naturaltime-past', '%d hour', '%d hours'), - 'minute': npgettext_lazy('naturaltime-past', '%d minute', '%d minutes'), + 'year': npgettext_lazy('naturaltime-past', '%(num)d year', '%(num)d years', 'num'), + 'month': npgettext_lazy('naturaltime-past', '%(num)d month', '%(num)d months', 'num'), + 'week': npgettext_lazy('naturaltime-past', '%(num)d week', '%(num)d weeks', 'num'), + 'day': npgettext_lazy('naturaltime-past', '%(num)d day', '%(num)d days', 'num'), + 'hour': npgettext_lazy('naturaltime-past', '%(num)d hour', '%(num)d hours', 'num'), + 'minute': npgettext_lazy('naturaltime-past', '%(num)d minute', '%(num)d minutes', 'num'), } future_substrings = { # Translators: 'naturaltime-future' strings will be included in '%(delta)s from now' - 'year': npgettext_lazy('naturaltime-future', '%d year', '%d years'), - 'month': npgettext_lazy('naturaltime-future', '%d month', '%d months'), - 'week': npgettext_lazy('naturaltime-future', '%d week', '%d weeks'), - 'day': npgettext_lazy('naturaltime-future', '%d day', '%d days'), - 'hour': npgettext_lazy('naturaltime-future', '%d hour', '%d hours'), - 'minute': npgettext_lazy('naturaltime-future', '%d minute', '%d minutes'), + 'year': npgettext_lazy('naturaltime-future', '%(num)d year', '%(num)d years', 'num'), + 'month': npgettext_lazy('naturaltime-future', '%(num)d month', '%(num)d months', 'num'), + 'week': npgettext_lazy('naturaltime-future', '%(num)d week', '%(num)d weeks', 'num'), + 'day': npgettext_lazy('naturaltime-future', '%(num)d day', '%(num)d days', 'num'), + 'hour': npgettext_lazy('naturaltime-future', '%(num)d hour', '%(num)d hours', 'num'), + 'minute': npgettext_lazy('naturaltime-future', '%(num)d minute', '%(num)d minutes', 'num'), } @classmethod diff --git a/django/utils/timesince.py b/django/utils/timesince.py index a9e6b61959..157dcb72c2 100644 --- a/django/utils/timesince.py +++ b/django/utils/timesince.py @@ -6,12 +6,12 @@ from django.utils.timezone import is_aware, utc from django.utils.translation import gettext, ngettext_lazy TIME_STRINGS = { - 'year': ngettext_lazy('%d year', '%d years'), - 'month': ngettext_lazy('%d month', '%d months'), - 'week': ngettext_lazy('%d week', '%d weeks'), - 'day': ngettext_lazy('%d day', '%d days'), - 'hour': ngettext_lazy('%d hour', '%d hours'), - 'minute': ngettext_lazy('%d minute', '%d minutes'), + 'year': ngettext_lazy('%(num)d year', '%(num)d years', 'num'), + 'month': ngettext_lazy('%(num)d month', '%(num)d months', 'num'), + 'week': ngettext_lazy('%(num)d week', '%(num)d weeks', 'num'), + 'day': ngettext_lazy('%(num)d day', '%(num)d days', 'num'), + 'hour': ngettext_lazy('%(num)d hour', '%(num)d hours', 'num'), + 'minute': ngettext_lazy('%(num)d minute', '%(num)d minutes', 'num'), } TIMESINCE_CHUNKS = ( @@ -73,13 +73,13 @@ def timesince(d, now=None, reversed=False, time_strings=None, depth=2): since = delta.days * 24 * 60 * 60 + delta.seconds if since <= 0: # d is in the future compared to now, stop processing. - return avoid_wrapping(time_strings['minute'] % 0) + return avoid_wrapping(time_strings['minute'] % {'num': 0}) for i, (seconds, name) in enumerate(TIMESINCE_CHUNKS): count = since // seconds if count != 0: break else: - return avoid_wrapping(time_strings['minute'] % 0) + return avoid_wrapping(time_strings['minute'] % {'num': 0}) result = [] current_depth = 0 while i < len(TIMESINCE_CHUNKS) and current_depth < depth: @@ -87,7 +87,7 @@ def timesince(d, now=None, reversed=False, time_strings=None, depth=2): count = since // seconds if count == 0: break - result.append(avoid_wrapping(time_strings[name] % count)) + result.append(avoid_wrapping(time_strings[name] % {'num': count})) since -= seconds * count current_depth += 1 i += 1 diff --git a/tests/utils_tests/test_timesince.py b/tests/utils_tests/test_timesince.py index d30bf00ae9..d080f1b1c5 100644 --- a/tests/utils_tests/test_timesince.py +++ b/tests/utils_tests/test_timesince.py @@ -77,7 +77,12 @@ class TimesinceTests(TestCase): def test_second_before_equal_first_humanize_time_strings(self): time_strings = { - 'minute': npgettext_lazy('naturaltime-future', '%d minute', '%d minutes'), + 'minute': npgettext_lazy( + 'naturaltime-future', + '%(num)d minute', + '%(num)d minutes', + 'num', + ), } with translation.override('cs'): for now in [self.t, self.t - self.onemicrosecond, self.t - self.oneday]: