Hi everybody, I´m developing my first web2py application with form.custom.widgets and I want to change at once all validations message of my form to the pt-br.py definitions (translations).
What I know: 1) I can define my validation messages in db,py, (I don´t want do it) 2) I have languages/pt-br.py with the translations of all validation messages that I want to use 3) I have the file application/admin/layout.html with an example of language switch wich I copied and tried to reproduce without success After several tries I always have back the default english messages, ex. value already in database or empty So, how I make the pt-br.py portuguese messages as default? Bellow follows the code: controller: default.py from gluon.admin import * from gluon.fileutils import abspath, read_file, write_file from glob import glob from gluon.tools import Crud import shutil import platform crud = Crud(db) def cadastro_pf(): table=db.pf form = crud.update(table,request.args(0)) table.id.represent = lambda id, row: \ A('edit:',id,_href=URL(args=(table,id))) search, rows = crud.search(table) return dict(form=form,search=search,rows=rows) view: cadastro_pf.html {{extend 'layout.html'}} <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="P3P" content="CP=\"IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA\"" /> <title>{{=response.title or URL()}}</title> {{response.files.append(URL('static','css/styles.css'))}} {{include 'web2py_ajax.html'}} <script>jQuery.noConflict();</script> </head> <body class="{{=T('direction: ltr') == 'direction: rtl' and 'RTLbody' or ''}} {{block sectionclass}}home{{end}}"> <h5>CADASTRO</h5> <!---------------------------------------------------------------------------------------------------------------- --> <div id="dados_pessoais"> <div style="background-color:#CCEEEE"><h6><font color=blue>SEUS DADOS</font></h6>{{=form.custom.begin}}</div> <div> nome*: <br>{{=form.custom.widget.nome}}</br> sobrenome*: <br>{{=form.custom.widget.sobrenome}}</br> email*: <br>{{=form.custom.widget.email}}</br> senha*: <br>{{=form.custom.widget.senha}}</br> sexo*: <br>{{=form.custom.widget.sexo}} </div> <div> <p></p>{{=INPUT(_type="submit", _name="submit", _value="Continua")}} </div> <div id="footer" class="fixed"> {{=T('Powered by')}} {{=A('web2py', _href='http://www.web2py.com')}}™ {{=T('created by')}} Massimo Di Pierro ©2007-2011 - {{if hasattr(T,'get_possible_languages'):}} <span> {{=T('Admin language')}} <select name="adminlanguage" onchange="var date = new Date();cookieDate=date.setTime(date.getTime()+(100*24*60*60*1000));document.cookie='adminLanguage='+this.options[this.selectedIndex].value+'; expires='+cookieDate+'; path=/';window.location.reload()"> {{for language in T.get_possible_languages():}} <option {{=T.accepted_language==language and 'selected' or ''}} >{{=language}}</option> {{pass}} </select> </span> {{pass}} </div> <!---------------------------------------------------------------------------------------------------------------- --> <div> <div style="background-color:#CCEEEE;"> </div> <div> <p></p>{{=INPUT(_type="submit", _name="submit", _value="Continua")}} </div> <div id="footer" class="fixed"> {{=T('Powered by')}} {{=A('web2py', _href='http://www.web2py.com')}}™ {{=T('created by')}} Massimo Di Pierro ©2007-2011 - {{if hasattr(T,'get_possible_languages'):}} <span> {{=T('Admin language')}} <select name="adminlanguage" onchange="var date = new Date();cookieDate=date.setTime(date.getTime()+(100*24*60*60*1000));document.cookie='adminLanguage='+this.options[this.selectedIndex].value+'; expires='+cookieDate+'; path=/';window.location.reload()"> {{for language in T.get_possible_languages():}} <option {{=T.accepted_language==language and 'selected' or ''}} >{{=language}}</option> {{pass}} </select> </span> {{pass}} </div> <!---------------------------------------------------------------------------------------------------------------- --> <font color="blue">_________________________________________</font> {{BEAUTIFY(request.vars)}} <font color="green">_________________________________________</font> {{BEAUTIFY(form.vars)}} <font color="red">_________________________________________</font> {{BEAUTIFY(form.errors)}} {{=form.custom.end}} </div> </body> </html>