常量字符串,并定义它们的请求之外,你可以使用一个懒惰的字符串。懒惰的字符串将不会进行评估,直到他们实际上是使用。要使用这样一个懒惰的字符串,使用lazy_gettext的()函数
Additionally if you want to use constant strings somewhere in your application and define them outside of a request, you can use a lazy strings. Lazy strings will not be evaluated until they are actually used. To use such a lazy string, use the lazy_gettext() function:
from flask.ext.babelex import lazy_gettext
class MyForm(formlibrary.FormBase):
success_message = lazy_gettext(u'The form was successfully saved.')
So how does Flask-BabelEx find the translations? Well first you have to create some.
http://pythonhosted.org/Flask-BabelEx/
Additionally if you want to use constant strings somewhere in your application and define them outside of a request, you can use a lazy strings. Lazy strings will not be evaluated until they are actually used. To use such a lazy string, use the lazy_gettext() function:
from flask.ext.babelex import lazy_gettext
class MyForm(formlibrary.FormBase):
success_message = lazy_gettext(u'The form was successfully saved.')
So how does Flask-BabelEx find the translations? Well first you have to create some.
http://pythonhosted.org/Flask-BabelEx/