Tuesday, October 2, 2012

Re: How to translate Lookup values in Django?

Thanks Juan. 

Well that is certainly possible. But then we have also some other lookups like the country, which is a lookup of 139 values. It would be difficult to keep that in the model itself. ;-)
But you are right about smaller lookups.

Regards,
Houman

On 3 Oct 2012, at 01:57, Juan Pablo Martínez <jpma55@gmail.com> wrote:

GENDER_CHOICES = (
('male', _(u'Male')),
('female', _(u'Female')),
)
gender      
= models.CharField(_(u'Sex'), max_length=10, choices=GENDER_CHOICES)


On Tue, Oct 2, 2012 at 7:23 PM, Houmie <houmie@gmail.com> wrote:

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.



--
juanpex

--
You received this message because you are subscribed to the Google Groups "Django users" group.
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