summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzu-ping Chung <uranusjr@gmail.com>2017-12-06 01:31:08 +0800
committerTim Graham <timograham@gmail.com>2017-12-06 09:42:58 -0500
commit85e6a1c634fed55c43090e37b802c721d9e7eaaa (patch)
treecf530ebc6097d789acf5e16ea89d0cb52d08b182
parent1818d13de792df0c8efd129c4e0927360e873e73 (diff)
Fixed #28877 -- Made ordinal template filter results more localizable.
Marked the whole pattern (e.g. "{value}th") as translatable, instead of just this suffix, so that languages not using suffixes for ordinals can use this tag.
-rw-r--r--django/contrib/humanize/locale/fr/LC_MESSAGES/django.mobin4174 -> 4609 bytes
-rw-r--r--django/contrib/humanize/locale/fr/LC_MESSAGES/django.po52
-rw-r--r--django/contrib/humanize/templatetags/humanize.py32
3 files changed, 70 insertions, 14 deletions
diff --git a/django/contrib/humanize/locale/fr/LC_MESSAGES/django.mo b/django/contrib/humanize/locale/fr/LC_MESSAGES/django.mo
index 6807322294..fdafcad708 100644
--- a/django/contrib/humanize/locale/fr/LC_MESSAGES/django.mo
+++ b/django/contrib/humanize/locale/fr/LC_MESSAGES/django.mo
Binary files differ
diff --git a/django/contrib/humanize/locale/fr/LC_MESSAGES/django.po b/django/contrib/humanize/locale/fr/LC_MESSAGES/django.po
index 142c6adbfa..74b863b4ce 100644
--- a/django/contrib/humanize/locale/fr/LC_MESSAGES/django.po
+++ b/django/contrib/humanize/locale/fr/LC_MESSAGES/django.po
@@ -10,8 +10,8 @@ msgstr ""
"Project-Id-Version: django\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-01-17 11:07+0100\n"
-"PO-Revision-Date: 2017-09-19 16:40+0000\n"
-"Last-Translator: Jannis Leidel <jannis@leidel.info>\n"
+"PO-Revision-Date: 2017-12-06 01:44+0800\n"
+"Last-Translator: Tzu-ping Chung <uranusjr@gmail.com>\n"
"Language-Team: French (http://www.transifex.com/django/django/language/fr/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -22,17 +22,49 @@ msgstr ""
msgid "Humanize"
msgstr "Humanisation"
-msgid "th"
-msgstr "<sup>e</sup>"
+msgctxt "ordinal 11, 12, 13"
+msgid "{}th"
+msgstr "{}<sup>e</sup>"
-msgid "st"
-msgstr "<sup>er</sup>"
+msgctxt "ordinal 0"
+msgid "{}th"
+msgstr "{}<sup>e</sup>"
-msgid "nd"
-msgstr "<sup>e</sup>"
+msgctxt "ordinal 1"
+msgid "{}st"
+msgstr "{}<sup>er</sup>"
-msgid "rd"
-msgstr "<sup>e</sup>"
+msgctxt "ordinal 2"
+msgid "{}nd"
+msgstr "{}<sup>e</sup>"
+
+msgctxt "ordinal 3"
+msgid "{}rd"
+msgstr "{}<sup>e</sup>"
+
+msgctxt "ordinal 4"
+msgid "{}th"
+msgstr "{}<sup>e</sup>"
+
+msgctxt "ordinal 5"
+msgid "{}th"
+msgstr "{}<sup>e</sup>"
+
+msgctxt "ordinal 6"
+msgid "{}th"
+msgstr "{}<sup>e</sup>"
+
+msgctxt "ordinal 7"
+msgid "{}th"
+msgstr "{}<sup>e</sup>"
+
+msgctxt "ordinal 8"
+msgid "{}th"
+msgstr "{}<sup>e</sup>"
+
+msgctxt "ordinal 9"
+msgid "{}th"
+msgstr "{}<sup>e</sup>"
#, python-format
msgid "%(value).1f million"
diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py
index fa644fd3a1..7b99d78f1e 100644
--- a/django/contrib/humanize/templatetags/humanize.py
+++ b/django/contrib/humanize/templatetags/humanize.py
@@ -23,11 +23,35 @@ def ordinal(value):
value = int(value)
except (TypeError, ValueError):
return value
- suffixes = (_('th'), _('st'), _('nd'), _('rd'), _('th'), _('th'), _('th'), _('th'), _('th'), _('th'))
- if value % 100 in (11, 12, 13): # special case
- return mark_safe("%d%s" % (value, suffixes[0]))
+ if value % 100 in (11, 12, 13):
+ # Translators: Ordinal format for 11 (11th), 12 (12th), and 13 (13th).
+ value = pgettext('ordinal 11, 12, 13', '{}th').format(value)
+ else:
+ templates = (
+ # Translators: Ordinal format when value ends with 0, e.g. 80th.
+ pgettext('ordinal 0', '{}th'),
+ # Translators: Ordinal format when value ends with 1, e.g. 81st, except 11.
+ pgettext('ordinal 1', '{}st'),
+ # Translators: Ordinal format when value ends with 2, e.g. 82nd, except 12.
+ pgettext('ordinal 2', '{}nd'),
+ # Translators: Ordinal format when value ends with 3, e.g. 83th, except 13.
+ pgettext('ordinal 3', '{}rd'),
+ # Translators: Ordinal format when value ends with 4, e.g. 84th.
+ pgettext('ordinal 4', '{}th'),
+ # Translators: Ordinal format when value ends with 5, e.g. 85th.
+ pgettext('ordinal 5', '{}th'),
+ # Translators: Ordinal format when value ends with 6, e.g. 86th.
+ pgettext('ordinal 6', '{}th'),
+ # Translators: Ordinal format when value ends with 7, e.g. 87th.
+ pgettext('ordinal 7', '{}th'),
+ # Translators: Ordinal format when value ends with 8, e.g. 88th.
+ pgettext('ordinal 8', '{}th'),
+ # Translators: Ordinal format when value ends with 9, e.g. 89th.
+ pgettext('ordinal 9', '{}th'),
+ )
+ value = templates[value % 10].format(value)
# Mark value safe so i18n does not break with <sup> or <sub> see #19988
- return mark_safe("%d%s" % (value, suffixes[value % 10]))
+ return mark_safe(value)
@register.filter(is_safe=True)