On 6 Jan 2014, at 1:55 PM, galoshes <moquin...@gmail.com> wrote: > Hello, I would like to revive this older thread (which also relates to this > one:https://groups.google.com/forum/#!topic/web2py/ff1syTIl12o). > > I'm new to web2py, and so far have been finding my way around ok (thanks to > the excellent docs), but the particular problem of mapping controllers and > functions to multi-language urls has me stumped. > > Here is what I would like to achieve: > 1. URLs appear in language of user: > app/news/latest (list of latest news in Eng) > app/nouvelles/recentes (maps to news/latest translated in Fr) > > 2. URLs rewritten when user toggles between languages (on news/latest page in > Eng, click 'French' button, get redirected to nouvelles/recentes page) > > 3. URLs in views appear in the language currently defined in the session. > > For example, if in layout.html, I have URL('news','latest'), it shows as > app/nouvelles/recentes when the session language is French. > > Would there be an elegant solution for achieving this?
web2py routing is not really set up to do this kind of thing. The nearest I can suggest is to have no routes.py, and: 1. Write a URL() wrapper that translates request.controller & request.function for outgoing URLs. 2. In your model (eg early in db.py), translate request.controller & request.function to the base language of the app. -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.