I upgrade from web2py 1.74.8 to latest trunk and then my admin can not
login normally, instead it generates error ticket. Tracing down the
bug, I found the reason and cure.
1. Since rev 146, web2py uses the browser's prefer language as the
default language setting. It is good. My browser's prefer language is
"zh-cn" (Chinese), it is also fine. But it happened that the current
Chinese language file, web2py\applications\admin\languages\zh-cn.py,
introduced by Jobinson in rev79 (http://code.google.com/p/web2py/
source/detail?r=063cc48352), is totally unacceptable. It contains the
unmatched-quotation syntax error, besides it does not finish
translation at all, many english strings are "translated" into empty
string, and some others are not translated precisely.
So the first suggestion, in my humble opinion, is to delete web2py
\applications\admin\languages\zh-cn.py. After all, a web2py developer/
user should be able to read all english words in admin app, so no need
to have a non-english version which is not likely to be always
synchronized with the official ones.
2. On the other hand, web2py's core code should be robust, to survive
a language file with syntax error inside (now we know it happens). So
the last line of function read_dict(filename) of web2py/gluon/
languages.py, should change into:
try:
return eval(lang_text)
except:
import logging
logging.exception('Syntax error in %s'%filename)
return {}
Regards,
Iceberg
Massimo
try:
return dict((k,v) for k,v in eval(lang_text).items()
if v) # to strip empty translation
except:
...
By the way, if you do feel reluctant to let go zh-cn.py, I can work
out a full translated version. But, although I know a "full set" of
strings to be translated can be obtained by clicking "update all
language" in admin, however there there is no "EDIT" page for appadmin
itself. So where can I start?
1. Open a tab in my Chrome to do the translate-submit-translate-submit
cycle
2. Open another tab, do something, such as testing another web2py app.
3. Switch back to tab #1, do a submit. Oops, all language pairs are
messed up. At this moment you have to cry if you don't have a backup.
Massimo might want to take a look about that.
Anyway, I finished the chinese translation. Will mail to Massimo in a
separate mail.