From f61d1432c7b57da5725a94c7b308ebacfe0af085 Mon Sep 17 00:00:00 2001 From: Alexis Metaireau Date: Sat, 15 Oct 2011 01:19:19 +0200 Subject: Translate the application using Flask-babel. The only translation so far is french, but more can be added. The browser language is used thanks to the HTTP languages headers. There are still some problems with the translation of some strings, I don't know why this is. See #12 --- budget/run.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'budget/run.py') diff --git a/budget/run.py b/budget/run.py index 39b297e..9bb07f4 100644 --- a/budget/run.py +++ b/budget/run.py @@ -1,4 +1,4 @@ -from web import main, db, mail +from web import main, db, mail, babel from api import api import os @@ -10,7 +10,6 @@ app.config.from_object("default_settings") app.register_blueprint(main) app.register_blueprint(api) - # db db.init_app(app) db.app = app @@ -19,6 +18,14 @@ db.create_all() # mail mail.init_app(app) +# translations +babel.init_app(app) + +@babel.localeselector +def get_locale(): + return request.accept_languages.best_match(['fr', 'en']) + + def main(): app.run(host="0.0.0.0", debug=True) -- cgit v1.1