Based on the selected language i send a different file to user when he/she 
registers

i user this

if any("adminLanguage=sl" in s for s in request.env.HTTP_COOKIE.split(";")):
    formFile = os.path.join(request.folder, 'private', 
'formular_WoShi_podatki.doc')
else:
    formFile = os.path.join(request.folder, 'private', 'form_WoShi_data.doc')




I know it is not the most elegant way so if anyone has a better 
suggestion.....

But it works :)



O Tuesday, March 14, 2017 at 8:39:09 PM UTC+8, 黄祥 wrote:
>
> perhaps you can use request.cookies
> e.g. taken from web2py admin app
> *models/db.py*
> if 'language' in request.cookies and not (request.cookies['language'] is 
> None):
>     T.force(request.cookies['language'].value)
> else:
> T.force('en')
>
> *views/language.html*
> {{extend 'layout.html'}}
>
> {{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>
> {{else:}}
> {{pass}}
>
> best regards,
> stifan
>

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