I want to convert Flask-WTF SelectField value with Flask-Babel.
Here is the snippet of my code:
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)
# ...
# ...
There, I want to localization the SelectField choices
value and QuerySelectField query_factory
value with Flask-Babel.
Is it possible..?, if so, any example or refer tutorial would be appreciated :)