I have a menu
MENU([['Users', False, URL(r=request,f='user',vars=dict(forced_language=session.lang))]])
and I want to translate Users
to other languages when I put T
before it like:
MENU([['T('Users')', False, URL(r=request,f='user',vars=dict(forced_language=session.lang))]])
But it causes invalid syntax, so how can I do that?
Also, h开发者_如何学编程ow do I use T
to translate words in view?
I want to translate word "language" in the following line:
language_multiselect_form=form_factory('a',SQLField('language',db.language,requires=IS_IN_DB(db,'language.id','language.name',multiple=True)))
Thanks in Advance
You have too many quotes:
MENU([[T('Users'), False, URL(r=request,f='user',vars=dict(forced_language=session.lang))]])
Translating strings in views in web2py should be rather easy:
<h2>Hello World</h2>
Would become:
<h2>{=T('Hello World')}</h2>
Or Even better:
<h2>{=XML(T('Hello World'))}</h2>
Use XML() to ensure proper escaping whenever possible.
Also, obviously you should have an available translation for your strings in your language dictionary for your application.
精彩评论