From 2b1d2dbc841d970ed369e6479693dcc80fa01233 Mon Sep 17 00:00:00 2001 From: asciimoo Date: Wed, 22 Jan 2014 00:17:49 +0100 Subject: [PATCH] [enh] i18n support --- searx/engines/__init__.py | 20 +++++++++++++++----- searx/templates/engines.html | 9 ++++----- searx/templates/index.html | 4 ++-- searx/templates/preferences.html | 8 ++++---- searx/templates/results.html | 6 +++--- searx/templates/stats.html | 2 +- 6 files changed, 29 insertions(+), 20 deletions(-) diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index bc7b3b3bc..96b074ae9 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -26,6 +26,7 @@ from searx import settings from searx.utils import gen_useragent import sys from datetime import datetime +from flask.ext.babel import gettext engine_dir = dirname(realpath(__file__)) @@ -269,15 +270,24 @@ def get_engines_stats(): engine['percentage'] = 0 return [ - ('Page loads (sec)', sorted(pageloads, key=itemgetter('avg'))), ( - 'Number of results', + gettext('Page loads (sec)'), + sorted(pageloads, key=itemgetter('avg')) + ), + ( + gettext('Number of results'), sorted(results, key=itemgetter('avg'), reverse=True) ), - ('Scores', sorted(scores, key=itemgetter('avg'), reverse=True)), ( - 'Scores per result', + gettext('Scores'), + sorted(scores, key=itemgetter('avg'), reverse=True) + ), + ( + gettext('Scores per result'), sorted(scores_per_result, key=itemgetter('avg'), reverse=True) ), - ('Errors', sorted(errors, key=itemgetter('avg'), reverse=True)), + ( + gettext('Errors'), + sorted(errors, key=itemgetter('avg'), reverse=True) + ), ] diff --git a/searx/templates/engines.html b/searx/templates/engines.html index 1f52dc09f..008e860f1 100644 --- a/searx/templates/engines.html +++ b/searx/templates/engines.html @@ -1,12 +1,12 @@ {% extends 'base.html' %} {% block content %}
-

Currently used search engines

+

{{ _('Currently used search engines') }}

- - + + {% for (categ,search_engines) in categs %} {% for search_engine in search_engines %} @@ -20,7 +20,6 @@ {% endfor %} {% endfor %}
Engine nameCategory{{ _('Engine name') }}{{ _('Category') }}
-

Please add more engines to this list, pull requests are welcome!

-

back

+

{{ _('back') }}

{% endblock %} diff --git a/searx/templates/index.html b/searx/templates/index.html index d9fa3b502..18320ae09 100644 --- a/searx/templates/index.html +++ b/searx/templates/index.html @@ -4,8 +4,8 @@

searx

{% include 'search.html' %}

- about - preferences + {{ _('about') }} + {{ _('preferences') }}

{% endblock %} diff --git a/searx/templates/preferences.html b/searx/templates/preferences.html index 705139e58..d47dd4834 100644 --- a/searx/templates/preferences.html +++ b/searx/templates/preferences.html @@ -2,18 +2,18 @@ {% block head %} {% endblock %} {% block content %}
-

Preferences

+

{{ _('Preferences') }}

- Default categories + {{ _('Default categories') }}

{% include 'categories.html' %}

- +
- +
{% endblock %} diff --git a/searx/templates/results.html b/searx/templates/results.html index 0fb9250ca..238671878 100644 --- a/searx/templates/results.html +++ b/searx/templates/results.html @@ -7,12 +7,12 @@
{% if suggestions %} -
Suggestions: {% for suggestion in suggestions %}
{% endfor %}
+
{{ _('Suggestions') }}:{% for suggestion in suggestions %}
{% endfor %}
{% endif %}
- Number of results: {{ number_of_results }} + {{ _('Number of results') }}: {{ number_of_results }}
{% for result in results %} @@ -23,7 +23,7 @@ {% endif %} {% endfor %}
- Download results + {{ _('Download results') }}
diff --git a/searx/templates/stats.html b/searx/templates/stats.html index 933616e32..cb5757b31 100644 --- a/searx/templates/stats.html +++ b/searx/templates/stats.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% block head %} {% endblock %} {% block content %} -

Engine stats

+

{{ _('Engine stats') }}

{% for stat_name,stat_category in stats %}