It worked, thanks. sexta-feira, 15 de Março de 2019 às 12:02:38 UTC, Leonel Câmara escreveu: > > This is how I do it in one of my websites > > in model: > > SUPPORTED_LANGUAGES = ('en', 'pt') # or just load this from config > > def pick_lang(): > twoletter = session.lang or T.accepted_language[:2] > if twoletter in SUPPORTED_LANGUAGES: > T.force(twoletter) > return twoletter > else: > T.force('en') > return 'en' > LANG = pick_lang() > > > Then default.py > > def language(): > """ Switch the site language """ > if request.args(0) in SUPPORTED_LANGUAGES: > session.lang = request.args(0) > redirect(request.vars._next) > > > In layout.html on the footer > > <ul class="nav nav-pills language-switcher order-3 col-4"> > <li role="presentation" {{if LANG == 'pt':}}class="active"{{pass > }}> > <a href="{{=URL('default', 'language', args='pt', > vars={'_next':URL(args=request.args, vars=request.vars)})}}">PT</a> > </li> > <li role="presentation" {{if LANG == 'en':}}class="active"{{pass > }}> > <a href="{{=URL('default', 'language', args='en', > vars={'_next':URL(args=request.args, vars=request.vars)})}}">EN</a> > </li> > </ul> > > > > > >
-- 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.