我想用Flask-Babel转换Flask-WTF SelectField 值。
这是我的代码片段:
from flask_babel import _, lazy_gettext as _l
class PaymentStatus(enum.Enum):
REJECTED = 'REJECTED'
COMPLETED = 'COMPLETED'
EXPIRED = 'EXPIRED'
def __str__(self):
return self.value
payment_status = [(str(y), y) for y in (PaymentStatus)]
def course_list():
return Course.query.all()
class PaymentForm(FlaskForm):
course_name = QuerySelectField(_l('Course name'), validators=[required()], query_factory=course_list)
status_of_payment = SelectField(_l('Payment Status'), choices=payment_status)
# ...
# ...
在那里,我想用Flask-Babelchoices
本地化 SelectField值和 QuerySelectFieldquery_factory
值。
是否有可能..?,如果是这样,任何示例或参考教程将不胜感激:)