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