thank you Wichert

appreciate your help

this is exactly what I did. My problem actually is how to import the _
function to use it within the translate_incoming(environ, match_dict)
function

daniel

On Jun 10, 9:31 am, Wichert Akkerman <[email protected]> wrote:
> On 2010-6-9 19:47, Gael Pasgrimaud wrote:
>
>
>
> > On Wed, Jun 9, 2010 at 6:35 PM, daniel<[email protected]>  wrote:
> >> Hello
>
> >> I'm working on an i18n project with pylons. I would need using _
> >> function from within routing.py
>
> >> If trying the following import into routing.py:
> >> from pylons.i18n.translation import _
>
> >> I get an error upon a browser request sending :
> >> TypeError: No object (name: translator) has been registered for this
> >> thread
>
> >> Apparentely there is some object missing at that stage
>
> >> Any help is greatly appreciated
>
> > I think that you can translate your urls at generation time:
>
> >     mapper('blog', '/{lang}/{slug}', controller=''...)
>
> > Then in templates/python code:
>
> >     from pylons.i18n import get_lang
> >     url('blog', lang=get_lang(), slug=_(slug_var))
>
> > (dont remember if get_lang() return a string or a list of all accepted
> > languages)
>
> What I found to be simpler is to leverage some route tricks. I have a
> route which looks like this:
>
>    map.connect("shop_category", "/shop/:category",
>                controller="shop", action="category",
>                conditions=dict(function=translate_incoming),
>                _filter=translate_outgoing)
>
>    def translate_incoming(environ, match_dict):
>        # ... translate the URL data in matchdict to canonical language
>
>    def translate_outgoing(match_dict):
>        # ... translate the URL data in match_dict to target language
>
> that will allow you to use one canonical language everywhere in your
> code, and routes will call your two translation things when needed.
>
> Wichert.
>
> --
> Wichert Akkerman <[email protected]>   It is simple to make 
> things.http://www.wiggy.net/                 It is hard to make things simple.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en.

Reply via email to