There are examples in the book [1]. [1] http://web2py.com/books/default/chapter/29/04/the-core#URL-rewrite
On Tue, Aug 27, 2013 at 1:08 PM, xelomac <[email protected]> wrote: > Thanks - good idea - but how do I force the URL to show the language token > like "domain.com/mayapp/en/mycontroller/myfunction"? > > On Tuesday, August 27, 2013 1:40:00 PM UTC+2, Massimo Di Pierro wrote: >> >> Look how admin does it: >> >> >> https://github.com/web2py/web2py/blob/master/applications/admin/views/layout.html#L62 >> >> https://github.com/web2py/web2py/blob/master/applications/admin/models/0.py#L79 >> >> >> On Tuesday, 27 August 2013 06:00:57 UTC-5, xelomac wrote: >>> >>> >>> >>> Hi folks, >>> >>> I'm working on a multilingual CMS. Therefore I need to give the site >>> visitor the option to change the content language using a language switcher >>> menu link. My question is about changing content language not about changing >>> surface language (please no T function answers here :-) >>> >>> So far I did the following: I created a routes.py file inside the web2py >>> directory with the following content: >>> >>> routers = dict( >>> BASE = dict(default_application='myapp'), >>> myapp = dict(languages=['en', 'it', 'fr', 'de'], >>> default_language='en'), >>> ) >>> >>> I found an older post dealing with this topic >>> (https://groups.google.com/forum/#!msg/web2py/q2B9mekNCwk/Kn-uxao1aIMJ) and >>> followed this advice: >>> >>>> URL() by default produces absolute scheme-less URLs, like this /a/c/f. >>>> so to link from http://site.com/en/a/c/f to http://site.com/fr/a/c/f, >>>> you prepend URL() call with '/fr', like this: >>>> <a href="/fr{{=URL(a=request.application, c=request.controller, >>>> f=request.function, ...)}}">French</a> >>> >>> >>> >>> This works - but only once. The first time I click the link the 'fr' is >>> prepended and the request.uri_language is changed accordingly. But on the >>> second click on a language link another language token is prepended to the >>> URI which breaks the app. (URL after second click reads like this: >>> domain.com/app/en/fr/controller/function) >>> >>> By the way: It only works on the first click because initially there is >>> no language token in the URI. But this means there would be pages that can >>> be reached with and without language token which will lead to Google >>> duplicate content problems. So I will have to find a solution that addresses >>> this issue too. >>> >>> Any help appreciated! >>> >>> >>> > -- > > --- > 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. -- --- 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.

