django translation does not happen for a field using choices..
models.py:
class Reservation(models.Model):
class Period:
MORNING = 'morning'
EVENING = 'evening'
@classmethod
def choices(cls):
return (
(cls.MORNING, _('Morning')),
(cls.EVENING, '{} until {:%I %p}'.format(_('Evening'), datetime.time(16)),
)
period = models.CharField(max_length=10, choices=Period.choices(),)
I am using {{ reservation.get_period_display }} in the template to display the field in few languages.Translation is fine for first choice cls.MORNING: الصباح. For the second choice (cls.EVENING), translation does not happen:"Evening until 04 PM"
Can anyone suggest me what is wrong with the format specifier, and why translation/localization is not working in this case.
N.B: The translation and i18n is setup properly and other places in my project is correctly showing translated values.