lingthio / Flask-User

Customizable User Authorization & User Management: Register, Confirm, Login, Change username/password, Forgot password and more.
http://flask-user.readthedocs.io/
MIT License
1.06k stars 294 forks source link

Flask-BabelEx is being deprecated #327

Open brendanbank opened 3 years ago

brendanbank commented 3 years ago

Hi, It looks like BabelEx is being deprecated, and all "All Flask-BabelEx features were merged into Flask-Babel," See Readme on the BabelEx repository.

I had to do the following to make Flask-Babel play nice with Flask-User:

  1. Patch flask_user/translation_utils.py

    
    diff --git a/flask_user/translation_utils.py b/flask_user/translation_utils.py
    index a878bca..cdabb0f 100644
    --- a/flask_user/translation_utils.py
    +++ b/flask_user/translation_utils.py
    @@ -12,7 +12,7 @@ _translations_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 't
    
    # Load Flask-User translations, if Flask-BabelEx has been installed
    try:
    -    from flask_babelex import Domain
    +    from flask_babel import Domain
    
     # Retrieve Flask-User translations from the flask_user/translations directory
     domain_translations = Domain(_translations_dir, domain='flask_user')
2. However, it looks like babel requires you to compile the translations for them to be used:

MacBookProII:flask_user brendan$ pybabel compile translations/flask_user.pot -d translations -D flask_user compiling catalog translations/sk/LC_MESSAGES/flask_user.po to translations/sk/LC_MESSAGES/flask_user.mo compiling catalog translations/pl/LC_MESSAGES/flask_user.po to translations/pl/LC_MESSAGES/flask_user.mo compiling catalog translations/sv/LC_MESSAGES/flask_user.po to translations/sv/LC_MESSAGES/flask_user.mo compiling catalog translations/it/LC_MESSAGES/flask_user.po to translations/it/LC_MESSAGES/flask_user.mo compiling catalog translations/ru/LC_MESSAGES/flask_user.po to translations/ru/LC_MESSAGES/flask_user.mo compiling catalog translations/zh/LC_MESSAGES/flask_user.po to translations/zh/LC_MESSAGES/flask_user.mo compiling catalog translations/uk/LC_MESSAGES/flask_user.po to translations/uk/LC_MESSAGES/flask_user.mo compiling catalog translations/nl/LC_MESSAGES/flask_user.po to translations/nl/LC_MESSAGES/flask_user.mo compiling catalog translations/de/LC_MESSAGES/flask_user.po to translations/de/LC_MESSAGES/flask_user.mo compiling catalog translations/fi/LC_MESSAGES/flask_user.po to translations/fi/LC_MESSAGES/flask_user.mo compiling catalog translations/fr/LC_MESSAGES/flask_user.po to translations/fr/LC_MESSAGES/flask_user.mo compiling catalog translations/es/LC_MESSAGES/flask_user.po to translations/es/LC_MESSAGES/flask_user.mo compiling catalog translations/en/LC_MESSAGES/flask_user.po to translations/en/LC_MESSAGES/flask_user.mo compiling catalog translations/fa/LC_MESSAGES/flask_user.po to translations/fa/LC_MESSAGES/flask_user.mo compiling catalog translations/tr/LC_MESSAGES/flask_user.po to translations/tr/LC_MESSAGES/flask_user.mo



The only issue I can think of is when you install Flask-User without [Babel](http://babel.pocoo.org/en/latest/), [Gnu gettext/msgfmt](https://www.gnu.org/software/gettext/) or [python-gettext](https://pypi.org/project/python-gettext/) installed: how would you compile the translations at the moment of installation. A workaround would be to add in the Flask-User installation instructions to compile post pip or pipenv installation.

Let me know if you need any more information. Happy to help.

Best regards,

 - Brendan
Chaostheorie commented 3 years ago

This problem has been discussed before in #195. The project seems on hiatus ATM as there were no updates for over a year. Would support this change though.