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 -~----------~----~----~----~------~----~------~--~---