[web2py] Re: Howto change request.uri_language through URL function?
On Aug 31, 10:44 pm, Alexander Cabezas wrote: > Did you build it with web2py? No, that website is powered by PHP. > How could I do the same thing in my application? As Massimo mentioned here (https://groups.google.com/d/msg/web2py/ q2B9mekNCwk/tUmqU0Iu-ZIJ), with the exception that in the model (db.py) you put, instead of > T.force(request.lang) this (from here (https://groups.google.com/d/msg/web2py/fpFJQlI21w4/ M1BWlGkB6v8J)) > if request.uri_language: T.force(request.uri_language) it works well with welcome application. this is severely underdocumented in the book! i18n section (http:// www.web2py.com/book/default/chapter/04#T-and-Internationalization) needs extending. but now that I read your post again, and as I understand, I don't think you can do it. you can't link from http://site.com/en/content to http://site.com/fr/content with URL(). in order to be able to do so, URL needs a lang parameter, so one can do: French lang must come in between application and controller. EDIT: disregard half. you can hack it. 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: French HTH?
[web2py] Re: Howto change request.uri_language through URL function?
Christopher Did you make this website? http://www.amnesty.org/fr/how-you-can-help Did you build it with web2py? How could I do the same thing in my application? On 29 ago, 23:40, Christopher Steel wrote: > So something like this: > > http://www.amnesty.org/fr/how-you-can-help > > and not this: > > http://voiceofaccess.org/init/default/index?_language=fr-ca > > ?
[web2py] Re: Howto change request.uri_language through URL function?
Something like this: http://www.amnesty.org/fr/how-you-can-help On 29 ago, 23:40, Christopher Steel wrote: > So something like this: > > http://www.amnesty.org/fr/how-you-can-help > > and not this: > > http://voiceofaccess.org/init/default/index?_language=fr-ca > > ?
Re: [web2py] Re: Howto change request.uri_language through URL function?
On Aug 29, 2011, at 9:26 PM, Jonathan Lundell wrote: > On Aug 29, 2011, at 8:50 PM, Massimo Di Pierro wrote: > >> The parametric router allows: >> >> routers = dict( >> # base router >> BASE = dict( >> default_application = app, >> ), >> app = dict( >> default_language = 'en', >> languages = ['en', 'it', 'pt', 'pt-br'], >> ), >> ) >> >> and than in the model you do: >> >> T.force(request.lang) >> >> Not clear whether anybody has ever tested this. > > Only unit tests. But the logic is pretty straightforward. There's one more step required: based on whatever user input you want to use to select the language in the first place, you need to set request.lang before calling URL, at least the first time. > >> >> Massimo >> >> >> On Aug 29, 2:26 pm, Alexander Cabezas wrote: >>> I want to change the application language through URL function, but >>> this doesn't expect the "lang" parameter. >>> >>> I did some tests with these >>> adresseshttp://127.0.0.1:8000/es-es/default/index >>> andhttp://127.0.0.1:8000/fr-fr/default/indexand it changed the >>> application language due to "gluon.rewrite". >>> >>> But I want to do this with URL function in order to put in the website >>> a Language Selector (SELECT and A tag). >>> >>> Massimo or somebody else, any clue? >
Re: [web2py] Re: Howto change request.uri_language through URL function?
On Aug 29, 2011, at 8:50 PM, Massimo Di Pierro wrote: > The parametric router allows: > > routers = dict( ># base router >BASE = dict( >default_application = app, >), >app = dict( >default_language = 'en', >languages = ['en', 'it', 'pt', 'pt-br'], >), > ) > > and than in the model you do: > > T.force(request.lang) > > Not clear whether anybody has ever tested this. Only unit tests. But the logic is pretty straightforward. > > Massimo > > > On Aug 29, 2:26 pm, Alexander Cabezas wrote: >> I want to change the application language through URL function, but >> this doesn't expect the "lang" parameter. >> >> I did some tests with these adresseshttp://127.0.0.1:8000/es-es/default/index >> andhttp://127.0.0.1:8000/fr-fr/default/indexand it changed the >> application language due to "gluon.rewrite". >> >> But I want to do this with URL function in order to put in the website >> a Language Selector (SELECT and A tag). >> >> Massimo or somebody else, any clue?
[web2py] Re: Howto change request.uri_language through URL function?
The parametric router allows: routers = dict( # base router BASE = dict( default_application = app, ), app = dict( default_language = 'en', languages = ['en', 'it', 'pt', 'pt-br'], ), ) and than in the model you do: T.force(request.lang) Not clear whether anybody has ever tested this. Massimo On Aug 29, 2:26 pm, Alexander Cabezas wrote: > I want to change the application language through URL function, but > this doesn't expect the "lang" parameter. > > I did some tests with these adresseshttp://127.0.0.1:8000/es-es/default/index > andhttp://127.0.0.1:8000/fr-fr/default/indexand it changed the > application language due to "gluon.rewrite". > > But I want to do this with URL function in order to put in the website > a Language Selector (SELECT and A tag). > > Massimo or somebody else, any clue?
[web2py] Re: Howto change request.uri_language through URL function?
So something like this: http://www.amnesty.org/fr/how-you-can-help and not this: http://voiceofaccess.org/init/default/index?_language=fr-ca ?