equal
deleted
inserted
replaced
10 from flask.ext.babel import gettext as _ |
10 from flask.ext.babel import gettext as _ |
11 from flask.ext.babel import Babel |
11 from flask.ext.babel import Babel |
12 |
12 |
13 from config import LANGUAGES |
13 from config import LANGUAGES |
14 |
14 |
|
15 LANGUAGE_SELECTED = None |
15 |
16 |
16 app = Flask(__name__) |
17 app = Flask(__name__) |
17 babel = Babel(app) |
18 babel = Babel(app) |
18 |
19 |
19 @babel.localeselector |
20 @babel.localeselector |
20 def get_locale(): |
21 def get_locale(): |
21 """ToDo: if translation is completed, switch to en """ |
22 """ToDo: if translation is completed, switch to en """ |
22 return request.accept_languages.best_match(LANGUAGES.keys()) or 'de' |
23 return LANGUAGE_SELECTED or request.accept_languages.best_match(LANGUAGES.keys()) or 'de' |
23 |
24 |
24 |
25 |
25 @app.route("/") |
26 @app.route("/") |
26 |
|
27 @app.route("/index") |
27 @app.route("/index") |
28 def index(): |
28 def index(): |
29 return render_template(get_locale() + "/index.html") |
29 return render_template(get_locale() + "/index.html") |
|
30 |
|
31 @app.route('/de') |
|
32 def de(): |
|
33 global LANGUAGE_SELECTED |
|
34 LANGUAGE_SELECTED = "de" |
|
35 return render_template("/de/index.html") |
|
36 |
|
37 @app.route('/en') |
|
38 def en(): |
|
39 global LANGUAGE_SELECTED |
|
40 LANGUAGE_SELECTED = "en" |
|
41 return render_template("/en/index.html") |
30 |
42 |
31 @app.route("/competition") |
43 @app.route("/competition") |
32 def competition(): |
44 def competition(): |
33 return render_template(get_locale() + "/competition.html", act="competition") |
45 return render_template(get_locale() + "/competition.html", act="competition") |
34 |
46 |