Use g.gettext for translations

This commit is contained in:
2014-12-17 19:00:42 +01:00
parent b4fc831f06
commit c278ff30f0
10 changed files with 87 additions and 56 deletions

View File

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