[enh] i18n support

This commit is contained in:
asciimoo 2014-01-22 00:17:49 +01:00
parent a1f945d227
commit 2b1d2dbc84
6 changed files with 29 additions and 20 deletions

View file

@ -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)
),
]

View file

@ -1,12 +1,12 @@
{% extends 'base.html' %}
{% block content %}
<div class="row">
<h2>Currently used search engines</h2>
<h2>{{ _('Currently used search engines') }}</h2>
<table style="width: 80%;">
<tr>
<th>Engine name</th>
<th>Category</th>
<th>{{ _('Engine name') }}</th>
<th>{{ _('Category') }}</th>
</tr>
{% for (categ,search_engines) in categs %}
{% for search_engine in search_engines %}
@ -20,7 +20,6 @@
{% endfor %}
{% endfor %}
</table>
<p>Please add more engines to this list, pull requests are welcome!</p>
<p class="right"><a href="/">back</a></p>
<p class="right"><a href="/">{{ _('back') }}</a></p>
</div>
{% endblock %}

View file

@ -4,8 +4,8 @@
<div class="title"><h1>searx</h1></div>
{% include 'search.html' %}
<p class="top_margin">
<a href="/about" class="hmarg">about</a>
<a href="/preferences" class="hmarg">preferences</a>
<a href="/about" class="hmarg">{{ _('about') }}</a>
<a href="/preferences" class="hmarg">{{ _('preferences') }}</a>
</p>
</div>
{% endblock %}

View file

@ -2,18 +2,18 @@
{% block head %} {% endblock %}
{% block content %}
<div class="row">
<h2>Preferences</h2>
<h2>{{ _('Preferences') }}</h2>
<fieldset>
<legend>Default categories</legend>
<legend>{{ _('Default categories') }}</legend>
<form method="post" action="/preferences" id="search_form">
<p>
{% include 'categories.html' %}
</p>
<input type="submit" value="save" />
<input type="submit" value="{{ _('save') }}" />
</form>
</fieldset>
<div class="right"><a href="/">back</a></div>
<div class="right"><a href="/">{{ _('back') }}</a></div>
</div>
{% endblock %}

View file

@ -7,12 +7,12 @@
</div>
<div id="results">
{% if suggestions %}
<div id="suggestions"><span>Suggestions: </span>{% for suggestion in suggestions %}<form method="post" action="/"><input type="hidden" name="q" value="{{suggestion}}"><input type="submit" value="{{ suggestion }}" /></form>{% endfor %}</div>
<div id="suggestions"><span>{{ _('Suggestions') }}:</span>{% for suggestion in suggestions %}<form method="post" action="/"><input type="hidden" name="q" value="{{suggestion}}"><input type="submit" value="{{ suggestion }}" /></form>{% endfor %}</div>
{% endif %}
<div id ="result_count">
Number of results: {{ number_of_results }}
{{ _('Number of results') }}: {{ number_of_results }}
</div>
{% for result in results %}
@ -23,7 +23,7 @@
{% endif %}
{% endfor %}
<div id="apis">
Download results
{{ _('Download results') }}
<form method="post" action="/">
<div class="left">
<input type="hidden" name="q" value="{{ q }}" />

View file

@ -1,7 +1,7 @@
{% extends "base.html" %}
{% block head %} {% endblock %}
{% block content %}
<h2>Engine stats</h2>
<h2>{{ _('Engine stats') }}</h2>
{% for stat_name,stat_category in stats %}
<div class="left">