On Mon, 2007-07-23 at 15:20 +0200, Peter Melvyn wrote:
> Hi all,
> 
> 
> I have a box containing some static texts in different languages and I
> would like to plug-in into few pages as inclusion tag.
> 
> But I'm not able to find-out a way how to supply language code for its
> template name containing thos static text. I need something like this:
> 
> register.inclusion_tag('%s/tag_cust_support.html' %
> request.LANGUAGE_CODE, takes_context=True)(.....)

I'm not sure how you've got your code set up, but typically
register.inclusion_tag is executed precisely once: at import time. At
that point, there's not necessarily any concept of a current request.

The other problem here is that inclusion_tag creates the name of the tag
based on the name of the function passed to it. So you can only create
one tag from each function.

> 
> Please, is it somehow possible to access language code of current session
> or I should pass those static text via underlying Python function?

If your template is passed a RequestContext, you have access to the
user's current locale settings (see the i18n documentation for details
and ignore the small bug that says there are two variables available and
then lists three things; three is the right number). So you might want
to create a tag that isn't based on inclusion_tag, but rather inspects
the requests locale and delivers the right content at rendering time.

Regards,
Malcolm



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