Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flask-BabelEx is being deprecated #327

Open
brendanbank opened this issue Nov 10, 2020 · 1 comment
Open

Flask-BabelEx is being deprecated #327

brendanbank opened this issue Nov 10, 2020 · 1 comment

Comments

@brendanbank
Copy link

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
@Chaostheorie
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants