You can use the admin page as a example of how to create a language select. 
I copied the following code with some modifications:

web2py/applications/admin/views/layout.html

<span>{{=T('Languages')}}</span>
{{if hasattr(T,'get_possible_languages_info'):}}
    <select name="language" onchange="var date = new Date();cookieDate=date.
setTime(date.getTime()+(100*24*60*60*1000));document.cookie='language='+this
.options[this.selectedIndex].id+'; expires='+cookieDate+'; 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>
</span>
{{else:}}
</span>
{{pass}}

web2py/applications/admin/models/0.py

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

On Thursday, July 5, 2012 4:01:55 AM UTC-7, Fernando J wrote:
>
> How is set a language selector in layout.html in order to any user may 
> select any language during his session?
>
> Thanks in advance
>
> Fernando J.
>

-- 

--- 
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