Jacob Kaplan-Moss wrote:
> On 1/11/07 2:35 PM, Nuno Mariz wrote:
>> Any idea to resolve this , this don't scale. If I what to add another 
>> language, I have to patch all of my templates.
> 
> If I were you, I'd write a simple accessor on your model to get the current 
> translation.  Off the top of my head, you could do something like::
> 
>       from django.utils import translation
> 
>       class MyModel(Model):
>               text_pt = TextField()
>               text_en = TextField()
> 
>               def get_text(self):
>                       text_field = "text_%s" % translation.get_language()
>                       return getattr(self, text_field)
> 
> Then in a template you can just do::
> 
>       {{ myobject.get_text }}
> 
> Jacob

Nice and simple, thanks Jacob

Nuno

--~--~---------~--~----~------------~-------~--~----~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to