Imagine a base class:
{{{
# gettext_lazy also does not work
from django.utils.translation import gettext as _
class SelectableModelField:
@classmethod
def make_choices(cls):
return [(value, _(key.replace('_', ' '))) for (key, value) in
vars(cls).items()
if not (key[-1] + key[0]).__contains__('_')]
bool_choices = ((True, 'Yes'), (False, 'No'))
}}}
which is inherited by:
{{{
class User(models.Model):
class __UserType__(SelectableModelField):
basic = 0
premium = 1
user_type =
models.PositiveSmallIntegerField(choices=__UserType__.make_choices())
}}}
the ''django.po'' file will not contain the functionally-generated choices
after running ''python manage.py makemessages -l ...''
--
Ticket URL: <https://code.djangoproject.com/ticket/34268>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* type: Cleanup/optimization => Uncategorized
--
Ticket URL: <https://code.djangoproject.com/ticket/34268#comment:1>
* severity: Release blocker => Normal
--
Ticket URL: <https://code.djangoproject.com/ticket/34268#comment:2>
* cc: Claude Paroz (added)
* status: new => closed
* resolution: => invalid
* type: Uncategorized => New feature
Comment:
Thanks for this ticket, however I don't think it's feasible (not only in
Django but in general). You can only translate a fixed list of strings.
--
Ticket URL: <https://code.djangoproject.com/ticket/34268#comment:3>