diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-01-11 15:37:05 +0100 |
---|---|---|
committer | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-01-13 11:36:46 +0100 |
commit | 09498a8887587df0096bcab5ffee62c757d38ae2 (patch) | |
tree | fd9f97f2b398c7e898db86bc6fe29ad12dfb3620 /ogcp/forms/auth.py | |
parent | 91f3567d0935da46b8064100952a3974cecc3a67 (diff) |
Use lazy translation in classes
From flask babel documentation:
---
Additionally if you want to use constant strings somewhere in your
application and define them outside of a request, you can use a lazy
strings. Lazy strings will not be evaluated until they are actually
used. To use such a lazy string, use the lazy_gettext() function.
---
_() and _l() functions are aliases of gettext() and lazy_gettext()
respectively. Both functions belong to flask babel library.
Diffstat (limited to 'ogcp/forms/auth.py')
-rw-r--r-- | ogcp/forms/auth.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ogcp/forms/auth.py b/ogcp/forms/auth.py index 3377cc3..72fc5c0 100644 --- a/ogcp/forms/auth.py +++ b/ogcp/forms/auth.py @@ -11,17 +11,18 @@ from wtforms import ( ) from wtforms.validators import InputRequired from flask_wtf import FlaskForm +from flask_babel import lazy_gettext as _l from flask_babel import _ class LoginForm(FlaskForm): user = StringField( - label=_('User'), + label=_l('User'), validators=[InputRequired()] ) pwd = PasswordField( - label=_('Password'), + label=_l('Password'), validators=[InputRequired()] ) submit = SubmitField( - label=_('Login') + label=_l('Login') ) |