Skip to content

Flask-BabelEx is being deprecated #327

Open
@brendanbank

Description

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')

  1. 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, Gnu gettext/msgfmt or 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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions