[mod] replace /translations.js by embedded JSON

In webapp.py, there is a new function "get_translations" lists available translations

Close #2064
This commit is contained in:
Alexandre Flament
2021-03-16 11:07:04 +01:00
parent cb3b379161
commit 6553c79029
17 changed files with 30 additions and 27 deletions

View File

@@ -362,6 +362,15 @@ def image_proxify(url):
urlencode(dict(url=url.encode(), h=h)))
def get_translations():
return {
# when overpass AJAX request fails (on a map result)
'could_not_load': gettext('could not load data'),
# when there is autocompletion
'no_item_found': gettext('No item found')
}
def render(template_name, override_theme=None, **kwargs):
disabled_engines = request.preferences.engines.get_disabled()
@@ -421,6 +430,8 @@ def render(template_name, override_theme=None, **kwargs):
kwargs['brand'] = brand
kwargs['translations'] = json.dumps(get_translations(), separators=(',', ':'))
kwargs['scripts'] = set()
kwargs['endpoint'] = 'results' if 'q' in kwargs else request.endpoint
for plugin in request.user_plugins:
@@ -1084,14 +1095,6 @@ def config():
})
@app.route('/translations.js')
def js_translations():
return render(
'translations.js.tpl',
override_theme='__common__',
), {'Content-Type': 'text/javascript; charset=UTF-8'}
@app.errorhandler(404)
def page_not_found(e):
return render('404.html'), 404