# HG changeset patch # User Reimar Bauer # Date 1390046428 -3600 # Node ID 8f3447e7f36e925e0ad52af28ff18047194282e5 # Parent b2340fb2beab552fe56cf20116253ad5f4be66c0 language selector from frontpage implemented diff -r b2340fb2beab -r 8f3447e7f36e pymove3d.py --- a/pymove3d.py Sat Jan 18 12:58:59 2014 +0100 +++ b/pymove3d.py Sat Jan 18 13:00:28 2014 +0100 @@ -12,6 +12,7 @@ from config import LANGUAGES +LANGUAGE_SELECTED = None app = Flask(__name__) babel = Babel(app) @@ -19,15 +20,26 @@ @babel.localeselector def get_locale(): """ToDo: if translation is completed, switch to en """ - return request.accept_languages.best_match(LANGUAGES.keys()) or 'de' + return LANGUAGE_SELECTED or request.accept_languages.best_match(LANGUAGES.keys()) or 'de' @app.route("/") - @app.route("/index") def index(): return render_template(get_locale() + "/index.html") +@app.route('/de') +def de(): + global LANGUAGE_SELECTED + LANGUAGE_SELECTED = "de" + return render_template("/de/index.html") + +@app.route('/en') +def en(): + global LANGUAGE_SELECTED + LANGUAGE_SELECTED = "en" + return render_template("/en/index.html") + @app.route("/competition") def competition(): return render_template(get_locale() + "/competition.html", act="competition")