On 13 Jan 2014, at 7:48 AM, Gael Princivalle <[email protected]> wrote: > That's a good solution, thanks. > > In the meantime I've found that you have to specify with C=...the controller > and f=... the functiuon in the URL helper. > > That like that it works fine: > {{response.menu.append(('IT', False, URL('it', f=request.function), [('EN', > False, URL('en', f=request.function), [])]))}}
The only problem with that is that the rewrite code for languages wants to treat the language differently from the controller. It might work, but only because the rewrite code is more clever than I remember. > > Thanks again for your help. > > Il giorno lunedì 13 gennaio 2014 16:22:50 UTC+1, Jonathan Lundell ha scritto: > On 13 Jan 2014, at 7:00 AM, Gael Princivalle <[email protected]> wrote: > > Thanks Alan, Jonathan. > > > > I've test more this simple solution: > > routers = dict( > > BASE = dict(default_application=' > > test'), > > test = dict(languages=['en', 'it'], default_language='it'), > > ) > > > > And it works fine for me. > > > > The only problem I have now if for switching between two languages > > reloading the current function. > > If fact if I switch with (in my menu): > > {{response.menu.append(('IT', False, URL('it', 'index'), [('EN', False, > > URL('en', 'index'), [])]))}} > > > > It works fine. > > If I try with request.function, request.function give me the language + the > > function: > > {{response.menu.append(('IT', False, URL('it', request.function), [('EN', > > False, URL('en', request.function), [])]))}} > > So if I have mydomain.com/it and I ask for english, web2py tries to load > > mydomain.com/it/en . KO. > > > > Is there an elegant way to avoid this problem of do I have to play with a > > session variable ? > > There's apparently a deficiency in URL that makes this difficult for you. URL > gets the language to insert into the outgoing URL from request.uri_language, > and has no language argument to override it. That could and should be fixed. > > In the meantime, here's a hack you could use (not tested). It needs to be > converted to template format, but you'll get the idea. > > uri_language = request.uri_language > urls = {} > for lang in ('it', 'en'): > request.uri_language = lang > urls[lang] = URL(request.function) > request.uri_language = uri_language > > {{response.menu.append(('IT', False, urls['it'], [('EN', False, urls['en'], > [])]))}} > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

