As you can see in my first post I used the example from the book. If I 
understand it right this solution allows to access a page in the preferred 
language by calling it with the URL containing the language token, set 
the request.uri_language and keep the language token for further navigation 
through the site. But I need the opposite direction. I need to change/add 
the language token to the URI after changing the language with the solution 
suggested by Massimo (language selector). 

If I get it right the routes example from the book gives a second option to 
retrieve the same document (as long as in default language) by using the 
URL with or without the language token (bad idea because of duplicate 
content punishment by Google).

What I am looking for is more a kind of a language specific permanent 
redirect (301) after changing the language using the language selector.

@Massimo: your solutions works half way for me but the select box shows 
only 17 of the 21 languages the same code offers when used in admin. For 
example German is missing. Any idea what's going wrong at this point?

On Tuesday, August 27, 2013 6:52:33 PM UTC+2, viniciusban wrote:
>
> 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]<javascript:>> 
> 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] <javascript:>. 
> > 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.

Reply via email to