mirror of
https://github.com/searxng/searxng.git
synced 2025-12-22 19:50:00 +00:00
[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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user