ambv/dj.choices

Use ugettext_lazy instead of ugettext

ffigiel opened this issue · 0 comments

When we retrieve a Choices list, ugettext is being evaluated. Sometimes this happens too early and translations are omitted, e.g. in form class body.

class MyForm(forms.Form):
    indexing = forms.ChoiceField(choices=core.IndexingModes())

A temporary workaround would look like this:

from django.utils.translation import ugettext_lazy as _

class MyForm(forms.Form):
    indexing = forms.ChoiceField(
        choices=[(id, _(desc)) for id, desc in core.IndexingModes()])