Thanks for the help Gael (merci) :)

Finally I try another method as routers.
Massimo and other talk about that in another post and a sample can be found 
in the admin page.

I add in my view a select with all language supported by my application. 
My application need to be compatible with ie9 so I suppress the expiration 
date otherwise IE9 doesn't create the cookie.

{{if hasattr(T,'get_possible_languages_info'):}}
<select style="margin-top: -5px;" name="userlanguage" 
onchange="document.cookie='userlanguage='+this.options[this.selectedIndex].id+';
 
path=/';window.location.reload()">
{{for langinfo in sorted([(code,info[1]) for code,info in T.
get_possible_languages_info().iteritems() if code != 'default']):}}
<option {{=T.accepted_language==langinfo[0] and 'selected' or ''}} {{='id='+
langinfo[0]}} >{{=langinfo[1]}}</option>
{{pass}}
</select>
{pass}}

in a new file 0.py in my models folder

# set the language
if 'userlanguage' in request.cookies and not (request.cookies['userlanguage'] 
is None):
T.force(request.cookies['userlanguage'].value)

I have now a language selector compatible with all browser and especially 
IE9...

Et encore merci pour ton aide :)

Olivier


Le vendredi 20 mars 2015 20:30:21 UTC+1, Gael Princivalle a écrit :
>
> And if you add at the end of the db.py file:
> if request.uri_language: T.force(request.uri_language)
>
> it will set the good language.
>
> Il giorno venerdì 20 marzo 2015 20:04:24 UTC+1, Gael Princivalle ha 
> scritto:
>>
>> Salut Olivier.
>>
>> I use that router and for me it works fine:
>> routers = dict(
>> BASE = dict(
>>         domains = {
>>     "www.mydomain.com" : "my_app", 
>> }
>> ),
>> my_app = dict(languages=['en', 'fr'], default_language='fr'),
>> )
>>
>> The original website (words in the .html files) have to be in english.
>>
>> After you must edit fr language file for applying translations.
>> For example:
>> T('A beautiful journey')
>> Load one time the .html page.
>> Search for 'A beautiful journey' in the fr language file.
>> Translate and save.
>>
>> For bigger contents make double fields in tables:
>> product_description_en
>> product_description_fr
>>
>> And in the .html file test which is the request.uri_language for 
>> displaying one or the other field.
>>
>> Hopes it could help, bye. 
>>
>> Il giorno mercoledì 18 marzo 2015 17:50:22 UTC+1, olivier hubert ha 
>> scritto:
>>>
>>> I try to made a simple multi language site with routes, but I can't.
>>> The routing are correct because I can use the url like this 
>>> http://127.0.0.1:8000/*testme*/en/ and *translate* application are 
>>> serve.
>>> But translate application is always in french!
>>>
>>> translate application is a copy of welcome application with the 
>>> modifications below.
>>>
>>> Web2Py version : 2.9.12-stable+timestamp.2015.01.17.06.11.03 (Running on 
>>> Rocket 1.2.6, Python 2.7.8)
>>>
>>> /web2py/routes.py
>>> ------------------------------
>>>
>>> routes_in = (
>>>   
>>> ('/testme/$language/(?P<any>.*)','/translate/default/$any?_language=$language'),
>>>  
>>> )
>>>
>>> /translate/models/0.py
>>> -----------------------------
>>>
>>> print request.vars
>>> if request.vars._language: 
>>>     T.force(request.vars._language)
>>>
>>> Terminal window return:
>>> ------------------
>>> <Storage {}>
>>>
>>>

-- 
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/d/optout.

Reply via email to