Skip to content

Instantly share code, notes, and snippets.

@leafsummer
Created April 29, 2019 08:41
Show Gist options
  • Save leafsummer/7b842df4d27bbc22c3eb08ddfdca6da5 to your computer and use it in GitHub Desktop.
Save leafsummer/7b842df4d27bbc22c3eb08ddfdca6da5 to your computer and use it in GitHub Desktop.
[wtforms translations]
from flask_wtf import FlaskForm
class MyFlaskForm(FlaskForm):
class Meta(FlaskForm.Meta):
def get_translations(self, form):
return get_translations(["zh", "en"])
def fetch_an_error(self):
message = ""
for _, messages in self.errors.iteritems():
if len(messages) > 0:
message = messages[0]
break
return message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment