Closed gikpro closed 1 year ago
Add this block of code to handle lazy gettext.
from wtforms import Form, StringField, validators as v
from wtforms import SubmitField
class lazy_gettext:
def __init__(self, message) -> None:
self.message = message
def __repr__(self) -> str:
return _(self.message)
class RegistrationForm(Form):
username = StringField(
lazy_gettext(_("Name")),
[v.InputRequired(lazy_gettext(_("Please provide your name")))],
)
submit = SubmitField(lazy_gettext(_("Submit")))
But I will add this feature to the new release. And if you would like you can contribute to our project and send a pull request.
Can we use this for WTForms fields ? Example
https://github.com/klen/asgi-babel/issues/1