diff options
| author | Alexis Metaireau <alexis@notmyidea.org> | 2011-10-15 01:19:19 +0200 |
|---|---|---|
| committer | Alexis Metaireau <alexis@notmyidea.org> | 2011-10-15 01:19:19 +0200 |
| commit | f61d1432c7b57da5725a94c7b308ebacfe0af085 (patch) | |
| tree | 74f2270c6f9bde7f5661d295253d3000e397b079 /budget/run.py | |
| parent | 45ccc8b509bc27f1301490272d71278a08bebe10 (diff) | |
| download | ihatemoney-mirror-f61d1432c7b57da5725a94c7b308ebacfe0af085.zip ihatemoney-mirror-f61d1432c7b57da5725a94c7b308ebacfe0af085.tar.gz ihatemoney-mirror-f61d1432c7b57da5725a94c7b308ebacfe0af085.tar.bz2 | |
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
Diffstat (limited to 'budget/run.py')
| -rw-r--r-- | budget/run.py | 11 |
1 files changed, 9 insertions, 2 deletions
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) |
