from django.utils import translation
translation.activate(language_code)
On Tue, Nov 3, 2009 at 10:43 AM, Till Backhaus <[email protected]> wrote:
>
> Hi django-users,
>
> how can i force django to render a template in a specific language?
>
> Consider this simple piece of code:
>
> t = get_template('internationalized_template.html')
> document = t.render(Context(locals()))
>
> The code is taken from an application where I create PDF files (via
> pisa) for
> all users of the site.
>
> Most times the code is called through a script, sometimes through the
> django
> admin, but never by the user himself.
>
> Now I want to set language that the template will be rendered in - i
> just don't
> see how to do it:
>
> According to the documentation LocaleMiddleware is responsible to
> determine what
> language should be used. When called through a script the middleware
> should not
> be involved and my assumption is, that the dummy gettext functions are
> used.
>
> What can I do to get django translate the template for me?
>
> Thanks in advance,
>
> Till Backhaus
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---