Skip to content

Instantly share code, notes, and snippets.

@mrf345
Created December 6, 2018 02:27
Show Gist options
  • Save mrf345/7ccea2d1d2f0726780c69923c6a7e586 to your computer and use it in GitHub Desktop.
Save mrf345/7ccea2d1d2f0726780c69923c6a7e586 to your computer and use it in GitHub Desktop.
Modified form with translation
class Touch_name(FlaskForm):
name = SelectField(coerce=str)
submit = SubmitField("Register")
def __init__(self, defLang='en', *args, **kwargs):
super(Touch_name, self).__init__(*args, **kwargs)
self.name.label = gtranslator.translate("Select one of the following options :", 'en', [defLang])
self.name.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in [
("First option", "First option"),
("Second option", "Second option"),
("Third option", "Third option")]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment