Question

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

Was it helpful?

Solution

You have too many quotes:

MENU([[T('Users'), False, URL(r=request,f='user',vars=dict(forced_language=session.lang))]])

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top