Skip to content

Commit

Permalink
Replace Flask-BabelEx with Flask-Babel
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelhwilliams committed Jul 16, 2024
1 parent 5a75ad3 commit 179bc94
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 37 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ Flask-Admin is built with the help of
[Bootswatch](http://bootswatch.com/).

If you want to localize your application, install the
[Flask-BabelEx](https://pypi.python.org/pypi/Flask-BabelEx) package.
[Flask-Babel](https://pypi.python.org/pypi/Flask-Babel) package.

You can help improve Flask-Admin\'s translations through Crowdin:
<https://crowdin.com/project/flask-admin>
15 changes: 7 additions & 8 deletions doc/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,23 @@ To add custom JavaScript or CSS in your *ModelView* use *extra_js* or *extra_css
extra_js = ['https://example.com/custom.js']
extra_css = ['https://example.com/custom.css']

Localization With Flask-Babelex
Localization With Flask-Babel
-------------------------------

****

Flask-Admin comes with translations for several languages.
Enabling localization is simple:

#. Install `Flask-BabelEx <http://github.com/mrjoes/flask-babelex/>`_ to do the heavy
lifting. It's a fork of the
`Flask-Babel <http://github.com/mitshuhiko/flask-babel/>`_ package::
#. Install `Flask-Babel <http://github.com/mrjoes/flask-babel/>`_ to do the heavy
lifting.

pip install flask-babelex
pip install flask-babel

#. Initialize Flask-BabelEx by creating instance of `Babel` class::
#. Initialize Flask-Babel by creating instance of `Babel` class::

from flask import Flask
from flask_babelex import Babel
from flask_babel import Babel

app = Flask(__name__)
babel = Babel(app)
Expand All @@ -67,7 +66,7 @@ Go ahead and add your own logic to the locale selector function. The application
a user profile, cookie, session, etc. It can also use the `Accept-Language`
header to make the selection automatically.

If the built-in translations are not enough, look at the `Flask-BabelEx documentation <https://pythonhosted.org/Flask-BabelEx/>`_
If the built-in translations are not enough, look at the `Flask-Babel documentation <https://pythonhosted.org/Flask-Babel/>`_
to see how you can add your own.

.. _file-admin:
Expand Down
2 changes: 1 addition & 1 deletion examples/babel/README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This example show how to translate Flask-Admin into different language using customized version of the `Flask-Babel <https://github.com/mrjoes/flask-babelex>`
This example show how to translate Flask-Admin into different language using customized version of the `Flask-Babel <https://github.com/mrjoes/flask-babel>`

To run this example:

Expand Down
2 changes: 1 addition & 1 deletion examples/babel/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from flask_sqlalchemy import SQLAlchemy

import flask_admin as admin
from flask_babelex import Babel
from flask_babel import Babel

from flask_admin.contrib import sqla

Expand Down
2 changes: 1 addition & 1 deletion examples/babel/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Flask
Flask-Admin
Flask-SQLAlchemy
Flask-BabelEx
Flask-Babel
2 changes: 1 addition & 1 deletion examples/sqla/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from flask import Flask, request, session
from flask_sqlalchemy import SQLAlchemy
from flask_babelex import Babel
from flask_babel import Babel


app = Flask(__name__)
Expand Down
2 changes: 1 addition & 1 deletion examples/sqla/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Flask
Flask-Admin
Flask-BabelEx
Flask-Babel
Flask-SQLAlchemy
tablib
enum34; python_version < '3.0'
Expand Down
5 changes: 1 addition & 4 deletions flask_admin/babel.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
try:
try:
from flask_babelex import Domain
except ImportError:
from flask_babel import Domain
from flask_babel import Domain

except ImportError:
def gettext(string, **variables):
Expand Down
2 changes: 1 addition & 1 deletion flask_admin/tests/sqla/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from flask_admin._compat import as_unicode
from flask_admin._compat import iteritems
from flask_admin.contrib.sqla import ModelView, filters, tools
from flask_babelex import Babel
from flask_babel import Babel

from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy import cast
Expand Down
2 changes: 1 addition & 1 deletion flask_admin/tests/sqla/test_translation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask_admin.babel import lazy_gettext
from flask_babelex import Babel
from flask_babel import Babel

from . import setup
from .test_basic import CustomModelView, create_models
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ module = [
"citext",
"colour",
"flask_babel",
"flask_babelex",
"flask_mongoengine.*",
"flask_wtf",
"google.appengine.ext",
Expand Down
13 changes: 5 additions & 8 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ babel==2.9.1
# -r docs.txt
# -r tests.in
# -r typing.txt
# flask-babelex
# flask-babel
# sphinx
cachetools==5.3.3
# via tox
Expand Down Expand Up @@ -116,11 +116,11 @@ flake8==3.9.2
flask==2.1.3
# via
# -r typing.txt
# flask-babelex
# flask-babel
# flask-mongoengine
# flask-sqlalchemy
# flask-wtf
flask-babelex==0.9.4
flask-babel==2.0.0
# via
# -r tests.in
# -r typing.txt
Expand Down Expand Up @@ -178,7 +178,7 @@ jinja2==3.0.0
# -r tests.in
# -r typing.txt
# flask
# flask-babelex
# flask-babel
# sphinx
lazy-object-proxy==1.9.0
# via
Expand Down Expand Up @@ -304,6 +304,7 @@ pytz==2024.1
# -r docs.txt
# -r typing.txt
# babel
# flask-babel
pyyaml==6.0.1
# via pre-commit
requests==2.31.0
Expand All @@ -326,10 +327,6 @@ snowballstemmer==2.2.0
# via
# -r docs.txt
# sphinx
speaklater==1.3
# via
# -r typing.txt
# flask-babelex
sphinx==5.3.0
# via
# -r docs.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/tests.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pymongo>=3.7.0
flask-mongoengine==0.8.2
pillow>=3.3.2
Babel<=2.9.1
flask-babelex
flask-babel
shapely>=2
geoalchemy2
psycopg2
Expand Down
14 changes: 7 additions & 7 deletions requirements/typing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ azure-storage-common==2.1.0
babel==2.9.1
# via
# -r tests.in
# flask-babelex
# flask-babel
certifi==2024.7.4
# via requests
cffi==1.15.1
Expand Down Expand Up @@ -52,11 +52,11 @@ flake8==3.9.2
# via -r tests.in
flask==2.1.3
# via
# flask-babelex
# flask-babel
# flask-mongoengine
# flask-sqlalchemy
# flask-wtf
flask-babelex==0.9.4
flask-babel==2.0.0
# via -r tests.in
flask-mongoengine==0.8.2
# via -r tests.in
Expand Down Expand Up @@ -85,7 +85,7 @@ jinja2==3.0.0
# via
# -r tests.in
# flask
# flask-babelex
# flask-babel
lazy-object-proxy==1.9.0
# via astroid
markupsafe==2.0.1
Expand Down Expand Up @@ -154,7 +154,9 @@ python-dateutil==2.9.0.post0
# arrow
# azure-storage-common
pytz==2024.1
# via babel
# via
# babel
# flask-babel
requests==2.31.0
# via
# azure-storage-common
Expand All @@ -165,8 +167,6 @@ six==1.16.0
# via
# flask-mongoengine
# python-dateutil
speaklater==1.3
# via flask-babelex
sqlalchemy==1.4.52
# via
# -r tests.in
Expand Down

0 comments on commit 179bc94

Please sign in to comment.