>
> from gluon import current
> from gluon.validators import IS_NOT_EMPTY, IS_IN_DB
> class FormTxt(object):
>    err_choose = current.T('choose one or more')
>    err_required = current.T('this is required')
>

The purpose of translation is to translate strings based on the requested 
language of a given HTTP request. What is the point of such a translation 
in the context of a one-time setting of class attributes? You have to pick 
a particular language for the translation, and then whatever language you 
pick will permanently determine the value of those attributes.

In any case, you don't want to use current.T for this purpose, as the T 
object associated with a given request has a particular translation 
language associated with it. Also, by default, T() returns a LazyT object, 
so the translation doesn't happen immediately (though you can force it).

If you need to translate something statically, you can instead import the 
translator class from gluon.languages and instantiate your own translator 
object (it takes a path to the translation files as well as a language). 
However, if you just want a fixed class attribute, you might as well just 
specify the string directly (particularly if you just want the English 
version) rather than invoke a one-time translation.

Anthony

-- 
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.

Reply via email to