In a Django project, I translate strings using ugettext
from the django.utils.translation
module. As an example, I translate strings in my models.py
.
Translation works perfectly, but not with crispy-forms. Why is that and how can I fix this?
Example models.py
:
from django.utils.translation import ugettext as _
class CustomerUser(models.Model):
LANGUAGE_CHOICES = (
('en', _('English')),
('de', _('German')),
)
name = models.CharField(null=False, blank=False, max_length=50)
user = models.ForeignKey(User, blank=True, null=True)
email = models.EmailField(blank=True, null=True)
language = models.CharField(choices=LANGUAGE_CHOICES, default='en', max_length=2)
customer = models.ForeignKey(Customer)
changed_password = models.BooleanField(default=False)
def __unicode__(self):
return self.name
In the view, I do the following:
from django.utils import translation
translation.activate('de')
but crispy forms aren't translated. The option from the language
is still rendered as "German" instead of "Deutsch".