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 *
@@ -48,10 +45,10 @@ class IWLADisplayTopDownloads(IPlugin):
if self.create_all_downloads:
filename = 'top_downloads.html'
path = self.iwla.getCurDisplayPath(filename)
title = time.strftime(g.gettext('All Downloads') + ' - %B %Y', self.iwla.getCurTime())
title = createCurTitle(self.iwla, u'All Downloads')
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
table = display.createBlock(DisplayHTMLBlockTable, g.gettext('All Downloads'), [g.gettext('URI'), g.gettext('Hit')])
table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'All Downloads'), [self.iwla._(u'URI'), self.iwla._(u'Hit')])
table.setColsCSSClass(['', 'iwla_hit'])
total_entrance = [0]*2
@@ -63,21 +60,21 @@ class IWLADisplayTopDownloads(IPlugin):
display.addPage(page)
title = g.gettext('Top Downloads')
title = self.iwla._(u'Top Downloads')
if self.create_all_downloads:
link = '<a href=\'%s\'>%s</a>' % (filename, g.gettext('All Downloads'))
link = '<a href=\'%s\'>%s</a>' % (filename, self.iwla._(u'All Downloads'))
title = '%s - %s' % (title, link)
# Top in index
index = self.iwla.getDisplayIndex()
table = display.createBlock(DisplayHTMLBlockTable, title, [g.gettext('URI'), g.gettext('Hits')])
table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'URI'), self.iwla._(u'Hits')])
table.setColsCSSClass(['', 'iwla_hit'])
for (uri, entrance) in top_downloads[:10]:
table.appendRow([generateHTMLLink(uri), entrance])
total_entrance[1] -= entrance
if total_entrance[1]:
total_entrance[0] = g.gettext('Others')
total_entrance[0] = self.iwla._(u'Others')
table.appendRow(total_entrance)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table)