I'm using flask_babelex in my app and the app translation itself works fine, but the flask-security part stays in english.
def create_app():
...
babel = Babel(app) # noqa: F841
...
security = Security( # noqa: F841
app, user_datastore, register_form=ExtendedRegisterForm, confirm_register_form=ExtendedRegisterForm
)
...
@babel.localeselector
def get_locale():
# if a user is logged in, use the locale from the user settings
identity = getattr(g, "identity", None)
if identity is not None and identity.id:
return identity.user.locale
# otherwise try to guess the language from the user accept
# header the browser transmits. We support fr/en in this
# example. The best match wins.
print(f"Best locale choosed: {request.accept_languages.best_match(AVAILABLE_LOCALES)}")
return request.accept_languages.best_match(AVAILABLE_LOCALES)
@babel.timezoneselector
def get_timezone():
identity = getattr(g, "identity", None)
if identity is not None and identity.id:
return identity.user.timezone
My get_locale returns "fr" as my browser have been set in french, but flask-security form labels and error messages stays in english.
Any ideas on how I can try to debug that ?
(running git+https://github.com/mattupstate/flask-security@develop#egg=Flask-Security actually because I need fixes not currently released)
I'm using flask_babelex in my app and the app translation itself works fine, but the flask-security part stays in english.
My
get_locale
returns "fr" as my browser have been set in french, but flask-security form labels and error messages stays in english.Any ideas on how I can try to debug that ?
(running
git+https://github.com/mattupstate/flask-security@develop#egg=Flask-Security
actually because I need fixes not currently released)