commit: 7a922b2ab8464f32ebed03d4c2b652159891fdc7
parent c54baf63015e884c060e10bc7a73a2c1503564c1
Author: Thomas Pointhuber <thomas.pointhuber@gmx.at>
Date: Fri, 14 Mar 2014 10:55:52 +0100
adding translations support for publish-date
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/searx/webapp.py b/searx/webapp.py
@@ -32,7 +32,7 @@ from flask import (
Flask, request, render_template, url_for, Response, make_response,
redirect, send_from_directory
)
-from flask.ext.babel import Babel
+from flask.ext.babel import Babel, gettext, ngettext, format_date
from searx import settings, searx_dir
from searx.engines import (
search as do_search, categories, engines, get_engines_stats,
@@ -162,11 +162,11 @@ def index():
if result['publishedDate'].date() == datetime.now().date():
timedifference = datetime.now()-result['publishedDate']
if timedifference.seconds < 60*60:
- result['publishedDate'] = '{0:d} minutes ago'.format(timedifference.seconds/60)
+ result['publishedDate'] = gettext(u'{0:d} minutes ago').format(timedifference.seconds/60)
else:
- result['publishedDate'] = '{0:d} hours ago'.format(timedifference.seconds/60/60)
+ result['publishedDate'] = gettext(u'{0:d} hours ago').format(timedifference.seconds/60/60)
else:
- result['publishedDate'] = result['publishedDate'].strftime('%d.%m.%Y')
+ result['publishedDate'] = format_date(result['publishedDate'])
if search.request_data.get('format') == 'json':
return Response(json.dumps({'query': search.query,