Tuesday, October 2, 2012

How to translate Lookup values in Django?

Django has an excellent support for internationalization, any English expression within Models, Forms, View or template can easily be marked for translation. However I came across an interesting situation I don't know how to deal with.

I have a Gender lookup (Male, Female). Now even if I translated the site into German, the Gender dropdown is still pointing to the values saved in database, which happens to be in English. So How am I supposed to mark the values in the database to be translated in PO files?

class Gender(models.Model):
    gender      
= models.CharField(_(u'Sex'), max_length=10)    
   
def __unicode__(self):
       
return self.gender
   
class Meta:
        verbose_name
= _(u'Sex')
        verbose_name_plural
= _(u'Sexes')


Many Thanks,

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/mLjpKAPU1NAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment