It's not an entire template, I'm just using the template system as an alternative to string formatting because of its name resolution capabilities. I found out how to do it, actually, I used ugettext instead of lazy an it works well!
Poromenos On 12 Απρ 2009, at 19:52, Karen Tracey <kmtra...@gmail.com> wrote: > On Sun, Apr 12, 2009 at 11:29 AM, Poromenos <porome...@gmail.com> > wrote: > > Hello, > I am trying to render a template in my models (to get the model > details in a printable format), but I want the template string to be > internationalised. ugettext_lazy does not return a string object, and > the template returns nothing. My code is: > > template = Template(_("{{ self.name }}")) > context = Context({"self": self}).render > return template.render(context) > > This fails. Is there something I can do , or do I have to forget about > internationalisation? Can I just use ugettext() instead? > > Have you read: http://docs.djangoproject.com/en/dev/topics/i18n/ > > particularly: > http://docs.djangoproject.com/en/dev/topics/i18n/#in-template-code > > ? > > You don't want to be translating an entire template, you want to > translate individual bits within the template. Consider that in > general a template will be filled with html tags, template > constructs (such as the {{ }} you have in yours), and such that it > makes no sense to translate. > > Karen > > > --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---