Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Consider Flask-Babel integration #18

Closed
mattupstate opened this issue Jun 18, 2012 · 9 comments
Closed

Consider Flask-Babel integration #18

mattupstate opened this issue Jun 18, 2012 · 9 comments

Comments

@mattupstate
Copy link
Collaborator

i10n and i18n could be necessary for things such as Flash messages.

@mattupstate
Copy link
Collaborator Author

If anyone has some experience with doing this, I've started a branch named messages. I've having a bit of a hard time getting this feature started. The implementation is based on the Flask-Admin implementation.

@abulte
Copy link
Contributor

abulte commented Apr 17, 2013

This could be a great feature indeed! 👍

@mattupstate
Copy link
Collaborator Author

Tell me about it. I haven't had much success getting it to work in the way that Flask-Admin has.

@abulte
Copy link
Contributor

abulte commented Apr 18, 2013

Maybe I can take a shot at it next week - if I can find the time. Not very experienced with Babel, but I would definitively use this feature. Anything I should know beforehand?

@mattupstate
Copy link
Collaborator Author

Not that I can think of. Flask-Admin seems to have it figured out, thats about all I have to contribute as of now.

@ChrisBuergi
Copy link

+1
Currently I encapsulate the strings from _default_messages and _default_email_subjects into the Flask-Babel lazy_gettext() and then set them into the app.config.

Unfortunately that doesn't work for _default_field_labels in forms.py. It might work if the definition of the _default_field_labels would be in another file, so it could be modified from the outside before the forms.py is imported. This is hacky and definitely not the best solution.

P.S. I use lazy_gettext() so the strings get translated on each access and not just once on initialization (or at least so I think, haven't tested it yet). This way the locale can change and the strings are then translated to the correct language.

@macic
Copy link

macic commented Dec 5, 2013

I guess there was no progress on this recently. I will try and work on this in upcoming days.

@yoursdearboy
Copy link
Contributor

In addition to Chris solution - to localize login message SECURITY_MSG_LOGIN it's also necessary to provide localize callback for login manager.

security = Security(app, user_datastore)
security.login_manager.localize_callback = lazy_gettext

@jirikuncar
Copy link
Collaborator

@yoursdearboy the Flask-BabelEx has been integrated in #617 (originally from inveniosoftware#33). Please check if it works for you and in case you have a problem open new issue. Thank you!

TillerBurr pushed a commit to TillerBurr/flask-security that referenced this issue May 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

6 participants