Should anybody need this, I customised the include tag (and copied it into 
templatetags).

The code:

from django.template.loader_tags import IncludeNode,ConstantIncludeNode

def do_i18n_include(parser, token):
    bits = token.contents.split()
    if len(bits) != 2:
        raise TemplateSyntaxError, "%r tag takes one argument: the name of the 
template to be included" % bits[0]
    path = bits[1]

    # @todo: fallback to 'en' if non existed locale helpfile is detected
    language = get_language()[0:2]
    i18npath = path.replace('.', '.'+language+'.')
    path = i18npath

    if path[0] in ('"', "'") and path[-1] == path[0]:
        return ConstantIncludeNode(path[1:-1])
    return IncludeNode(bits[1])

register.tag('my18n_include')(do_i18n_include)


Note: there's no fallback yet to a default for none existent locale files.

Regards,

Gerard.


Gerard Petersen wrote:
> Hi All,
> 
> I have an include tag to a file with context help information. My app is 
> fully i18n-ed, but I don't want to handle the bigger the helptext via i18n 
> because of its size. I want to end up with something like this: 
> myapp/customer_side.en.html.
> 
> The code snippet:
> 
> <div id="right">
>     {% include "myapp/customer_side.html" %}
> </div>
> 
> I'm thinking about a custom templatetag that picks up on the locale. Does 
> anybody have other suggestions on how to do this?
> 
> 
> Thanx a lot.
> 
> Regards,
> 
> Gerard.
> 
> 

-- 
urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }


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

Reply via email to