瀏覽代碼

Fixed #36102 -- Moved i18n comments directly above the translatable string.

xgettext only extracts comment blocks if there is no program code between
the comment and the string that gets extracted. For details, see:
https://www.gnu.org/software/gettext/manual/html_node/xgettext-Invocation.html#Operation-mode

Black formatting has been turned off in some places to ensure the
comments are not moved, which previously resulted in them being removed
from the po files when scripts/manage_translations.py was run.
Julien Palard 2 月之前
父節點
當前提交
6fcd0440aa
共有 1 個文件被更改,包括 22 次插入13 次删除
  1. 22 13
      django/contrib/humanize/templatetags/humanize.py

+ 22 - 13
django/contrib/humanize/templatetags/humanize.py

@@ -223,29 +223,36 @@ class NaturalTimeFormatter:
         # and time unit.
         "past-second": ngettext_lazy("a second ago", "%(count)s seconds ago", "count"),
         "now": gettext_lazy("now"),
-        # Translators: please keep a non-breaking space (U+00A0) between count
-        # and time unit.
+        # fmt: off
+        # fmt turned off to avoid black splitting the ngettext_lazy calls to multiple
+        # lines, as this results in gettext missing the 'Translators:' comments.
         "future-second": ngettext_lazy(
+            # Translators: please keep a non-breaking space (U+00A0) between count
+            # and time unit.
             "a second from now", "%(count)s seconds from now", "count"
         ),
-        # Translators: please keep a non-breaking space (U+00A0) between count
-        # and time unit.
         "future-minute": ngettext_lazy(
-            "a minute from now", "%(count)s minutes from now", "count"
+            # Translators: please keep a non-breaking space (U+00A0) between count
+            # and time unit.
+            "a minute from now", "%(count)s minutes from now", "count",
         ),
-        # Translators: please keep a non-breaking space (U+00A0) between count
-        # and time unit.
         "future-hour": ngettext_lazy(
-            "an hour from now", "%(count)s hours from now", "count"
+            # Translators: please keep a non-breaking space (U+00A0) between count
+            # and time unit.
+            "an hour from now", "%(count)s hours from now", "count",
         ),
+        # fmt: on
         # Translators: delta will contain a string like '2 months' or '1 month, 2 weeks'
         "future-day": gettext_lazy("%(delta)s from now"),
     }
     past_substrings = {
-        # Translators: 'naturaltime-past' strings will be included in '%(delta)s ago'
+        # fmt: off
         "year": npgettext_lazy(
-            "naturaltime-past", "%(num)d year", "%(num)d years", "num"
+            # Translators: 'naturaltime-past' strings will be included in
+            # '%(delta)s ago'
+            "naturaltime-past", "%(num)d year", "%(num)d years", "num",
         ),
+        # fmt:on
         "month": npgettext_lazy(
             "naturaltime-past", "%(num)d month", "%(num)d months", "num"
         ),
@@ -261,11 +268,13 @@ class NaturalTimeFormatter:
         ),
     }
     future_substrings = {
-        # Translators: 'naturaltime-future' strings will be included in
-        # '%(delta)s from now'.
+        # fmt: off
         "year": npgettext_lazy(
-            "naturaltime-future", "%(num)d year", "%(num)d years", "num"
+            # Translators: 'naturaltime-future' strings will be included in
+            # '%(delta)s from now'.
+            "naturaltime-future", "%(num)d year", "%(num)d years", "num",
         ),
+        # fmt: on
         "month": npgettext_lazy(
             "naturaltime-future", "%(num)d month", "%(num)d months", "num"
         ),