Commit 0c8c7ac6 authored by Petrus J.v.Rensburg's avatar Petrus J.v.Rensburg

Updates to 'localization' page.

parent 6a46e233
Localization
============
Flask-Admin uses the `Flask-BabelEx <http://github.com/mrjoes/flask-babelex/>`_ package to handle translations.
Flask-BabelEx is a fork of Flask-Babel with following features:
Flask-Admin makes it possible for you to serve your application in more than one language. To do this, it makes use of
the `Flask-BabelEx <http://github.com/mrjoes/flask-babelex/>`_ package for handling translations. This package is a
fork of the popular `Flask-Babel <http://github.com/mitshuhiko/flask-babel/>`_ package, with the following features:
1. It is API-compatible with Flask-Babel
2. It allows distribution of translations with Flask extensions
3. Much more configurable
3. It aims to be more configurable than Flask-Babel
If Flask-Admin can not import Flask-BabelEx, it disables localization support completely.
Currently *Flask-BabelEx* is the only supported way of enabling localization support in Flask-Admin.
How to enable localization
--------------------------
1. Initialize Flask-BabelEx by creating instance of `Babel` class::
1. Install Flask-BabelEx::
pip install flask-babelex
2. Initialize Flask-BabelEx by creating instance of `Babel` class::
from flask import app
from flask.ext.babelex import Babel
......@@ -22,7 +26,7 @@ How to enable localization
app = Flask(__name__)
babel = Babel(app)
2. Create locale selector function::
3. Create a locale selector function::
@babel.localeselector
def get_locale():
......@@ -30,7 +34,9 @@ How to enable localization
# user profile, cookie, session, etc.
return 'en'
3. Initialize Flask-Admin as usual.
4. Initialize Flask-Admin as usual.
You can check `babel` example to see localization in action. To change locale, add *?en=<locale name>* to the URL. For example, URL
can look like: `http://localhost:5000/admin/userview/?lang=fr <http://localhost:5000/admin/userview/?lang=fr>`_.
You can check the `babel` example to see localization in action. When running this example, you can change the
locale simply by adding a query parameter, like *?en=<locale name>* to the URL. For example, a French version of
the application should be accessible at:
`http://localhost:5000/admin/userview/?lang=fr <http://localhost:5000/admin/userview/?lang=fr>`_.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment