Select translation based on browser configuration, fixes #100

master
Pierre Jaury 8 years ago
parent 9f09e0c8e0
commit d4f93e39db

@ -40,6 +40,7 @@ migrate = flask_migrate.Migrate(app, db)
login_manager = flask_login.LoginManager() login_manager = flask_login.LoginManager()
login_manager.init_app(app) login_manager.init_app(app)
babel = flask_babel.Babel(app) babel = flask_babel.Babel(app)
translations = list(map(str, babel.list_translations()))
# Manager commnad # Manager commnad
manager = flask_script.Manager(app) manager = flask_script.Manager(app)
@ -48,6 +49,11 @@ manager.add_command('db', flask_migrate.MigrateCommand)
# Connect to the Docker socket # Connect to the Docker socket
dockercli = docker.Client(base_url=app.config['DOCKER_SOCKET']) dockercli = docker.Client(base_url=app.config['DOCKER_SOCKET'])
# Babel configuration
@babel.localeselector
def get_locale():
return flask.request.accept_languages.best_match(translations)
# Finally setup the blueprint and redirect / # Finally setup the blueprint and redirect /
from mailu import admin from mailu import admin
app.register_blueprint(admin.app, url_prefix='/admin') app.register_blueprint(admin.app, url_prefix='/admin')

Loading…
Cancel
Save