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.
This commit is contained in:
parent
1818d13de7
commit
85e6a1c634
Binary file not shown.
|
@ -10,8 +10,8 @@ msgstr ""
|
||||||
"Project-Id-Version: django\n"
|
"Project-Id-Version: django\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2015-01-17 11:07+0100\n"
|
"POT-Creation-Date: 2015-01-17 11:07+0100\n"
|
||||||
"PO-Revision-Date: 2017-09-19 16:40+0000\n"
|
"PO-Revision-Date: 2017-12-06 01:44+0800\n"
|
||||||
"Last-Translator: Jannis Leidel <jannis@leidel.info>\n"
|
"Last-Translator: Tzu-ping Chung <uranusjr@gmail.com>\n"
|
||||||
"Language-Team: French (http://www.transifex.com/django/django/language/fr/)\n"
|
"Language-Team: French (http://www.transifex.com/django/django/language/fr/)\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
@ -22,17 +22,49 @@ msgstr ""
|
||||||
msgid "Humanize"
|
msgid "Humanize"
|
||||||
msgstr "Humanisation"
|
msgstr "Humanisation"
|
||||||
|
|
||||||
msgid "th"
|
msgctxt "ordinal 11, 12, 13"
|
||||||
msgstr "<sup>e</sup>"
|
msgid "{}th"
|
||||||
|
msgstr "{}<sup>e</sup>"
|
||||||
|
|
||||||
msgid "st"
|
msgctxt "ordinal 0"
|
||||||
msgstr "<sup>er</sup>"
|
msgid "{}th"
|
||||||
|
msgstr "{}<sup>e</sup>"
|
||||||
|
|
||||||
msgid "nd"
|
msgctxt "ordinal 1"
|
||||||
msgstr "<sup>e</sup>"
|
msgid "{}st"
|
||||||
|
msgstr "{}<sup>er</sup>"
|
||||||
|
|
||||||
msgid "rd"
|
msgctxt "ordinal 2"
|
||||||
msgstr "<sup>e</sup>"
|
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
|
#, python-format
|
||||||
msgid "%(value).1f million"
|
msgid "%(value).1f million"
|
||||||
|
|
|
@ -23,11 +23,35 @@ def ordinal(value):
|
||||||
value = int(value)
|
value = int(value)
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
return value
|
return value
|
||||||
suffixes = (_('th'), _('st'), _('nd'), _('rd'), _('th'), _('th'), _('th'), _('th'), _('th'), _('th'))
|
if value % 100 in (11, 12, 13):
|
||||||
if value % 100 in (11, 12, 13): # special case
|
# Translators: Ordinal format for 11 (11th), 12 (12th), and 13 (13th).
|
||||||
return mark_safe("%d%s" % (value, suffixes[0]))
|
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
|
# 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)
|
@register.filter(is_safe=True)
|
||||||
|
|
Loading…
Reference in New Issue