﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28877	Improve translation flexibility of ordinal template tag results	Tzu-ping Chung	Tzu-ping Chung	"There are languages, e.g. Chinese, that do not use suffix, but prefix to indicate ordinals. The current implementation means that it is impossible to translate the suffixes to work with those languages. I understand this has its root in a much larger issue (#15156), but this can be fixed very trivially by including the whole format instead of just the suffix, something like:


{{{
@register.filter(is_safe=True)
def ordinal(value):
    """"""
    Convert an integer to its ordinal as a string. 1 is '1st', 2 is '2nd',
    3 is '3rd', etc. Works for any integer.
    """"""
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value
    formats = (_('%dth'), _('%dst'), _('%dnd'), _('%drd'), _('%dth'), _('%dth'), _('%dth'), _('%dth'), _('%dth'), _('%dth'))
    if value % 100 in (11, 12, 13):  # special case
        return mark_safe(formats[0] % (value,))
    return mark_safe(formats[value % 10] % (value,))
}}}


I can submit a pull request if this is considered reasonable."	Cleanup/optimization	closed	contrib.humanize	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
