Replace g.gettext by iwla._

Add createCurTitle() to factorize code
This commit is contained in:
2014-12-17 20:31:59 +01:00
parent c278ff30f0
commit ccab40b4e1
9 changed files with 68 additions and 84 deletions

View File

@@ -1,6 +1,3 @@
import time
import gettext as g
from iwla import IWLA
from iplugin import IPlugin
from display import *
@@ -46,12 +43,12 @@ class IWLADisplayTopHits(IPlugin):
# All in a file
if self.create_all_hits:
title = time.strftime(g.gettext('All Hits') + ' - %B %Y', self.iwla.getCurTime())
title = createCurTitle(self.iwla, u'All Hits')
filename = 'top_hits.html'
path = self.iwla.getCurDisplayPath(filename)
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
table = display.createBlock(DisplayHTMLBlockTable, g.gettext('All Hits'), [g.gettext('URI'), g.gettext('Entrance')])
table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'All Hits'), [self.iwla._(u'URI'), self.iwla._(u'Entrance')])
table.setColsCSSClass(['', 'iwla_hit'])
total_hits = [0]*2
new_list = self.max_hits and top_hits[:self.max_hits] or top_hits
@@ -64,19 +61,19 @@ class IWLADisplayTopHits(IPlugin):
title = 'Top Hits'
if self.create_all_hits:
link = '<a href=\'%s\'>%s</a>' % (filename, g.gettext('All Hits'))
link = '<a href=\'%s\'>%s</a>' % (filename, self.iwla._(u'All Hits'))
title = '%s - %s' % (title, link)
# Top in index
index = self.iwla.getDisplayIndex()
table = display.createBlock(DisplayHTMLBlockTable, title, [g.gettext('URI'), g.gettext('Entrance')])
table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'URI'), self.iwla._(u'Entrance')])
table.setColsCSSClass(['', 'iwla_hit'])
for (uri, entrance) in top_hits[:10]:
table.appendRow([generateHTMLLink(uri), entrance])
total_hits[1] -= entrance
if total_hits[1]:
total_hits[0] = g.gettext('Others')
total_hits[0] = self.iwla._(u'Others')
table.appendRow(total_hits)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table)