make blocklist plugin translatable

This commit is contained in:
Marcos Pinto 2007-07-20 22:08:48 +00:00
parent 8182b5ce9a
commit 48b0b106f5
4 changed files with 20 additions and 23 deletions

View File

@ -3,10 +3,10 @@
# Distributed under the same terms as Deluge
##
plugin_name = "Blocklist Importer"
plugin_name = _("Blocklist Importer")
plugin_author = "Steve 'Tarka' Smith"
plugin_version = "0.4"
plugin_description = """
plugin_description = _("""
Download and import various IP blocklists.
Currently this plugin can handle PeerGuardian (binary and text),
@ -18,7 +18,7 @@ A page with pointer to blocklist download sites is available on the
wiki:
http://dev.deluge-torrent.org/wiki/BlocklistPlugin
"""
""")
def deluge_init(deluge_path):
global path
@ -37,10 +37,10 @@ from ui import GTKConfig, GTKProgress
# List of formats supported. This is used to generate the UI list and
# specify the reader class. The last entry is for storage by the UI.
readers = {'p2bgz':["PeerGuardian P2B (GZip)", PGReader, None],
'pgtext':["PeerGuardian Text (Uncompressed)", TextReader, None],
'gzmule':["Emule IP list (GZip)", GZMuleReader, None],
'spzip':["SafePeer Text (Zipped)", PGZip, None]}
readers = {'p2bgz':[_("PeerGuardian P2B (GZip)"), PGReader, None],
'pgtext':[_("PeerGuardian Text (Uncompressed)"), TextReader, None],
'gzmule':[_("Emule IP list (GZip)"), GZMuleReader, None],
'spzip':[_("SafePeer Text (Zipped)"), PGZip, None]}
class BlocklistImport:
@ -87,7 +87,7 @@ class BlocklistImport:
filename=self.blockfile,
reporthook=self._download_update)
except IOError, (errno, strerr):
err = ui.GTKError("Couldn't download URL: %s"%strerr)
err = ui.GTKError(_("Couldn't download URL") + ": %s"%strerr)
self.gtkprog.stop()
return
@ -100,7 +100,7 @@ class BlocklistImport:
try:
reader = readers[ltype][1](self.blockfile)
except IOError, (errno, strerr):
err = ui.GTKError("Couldn't open blocklist file: %s"%strerr)
err = ui.GTKError(_("Couldn't open blocklist file") + ": %s"%strerr)
self.gtkprog.stop()
return
@ -118,7 +118,7 @@ class BlocklistImport:
self.gtkprog.import_prog()
except FormatException, (ex):
err = ui.GTKError("Format error in blocklist: %s"%ex)
err = ui.GTKError(_("Format error in blocklist") + ": %s"%ex)
self.gtkprog.stop()
reader.close()
return
@ -154,4 +154,3 @@ class BlocklistImport:
def update(self):
msg = "[Blocklist: %s entries]" % self.nimported
self.interface.statusbar_temp_msg += ' ' + msg

View File

@ -25,16 +25,16 @@ class PGReader:
hdr = unpack("l", buf)[0]
if hdr != -1:
print "LEADER IS",hdr
raise PGException("Invalid leader %d"%hdr)
raise PGException(_("Invalid leader") + " %d"%hdr)
magic = self.fd.read(3)
if magic != "P2B":
raise PGException("Invalid magic code")
raise PGException(_("Invalid magic code"))
buf = self.fd.read(1)
ver = ord(buf)
if ver != 1 and ver != 2:
raise PGException("Invalid version %d" % ver)
raise PGException(_("Invalid version") + " %d" % ver)
def next(self):
@ -57,4 +57,3 @@ class PGReader:
def close(self):
self.fd.close()

View File

@ -34,7 +34,7 @@ class TextBase:
match = self.re.search(txt)
if not match:
raise FormatException("Couldn't match on line %d: %s (%s)"%(self.count,txt,txt))
raise FormatException(_("Couldn't match on line") + " %d: %s (%s)"%(self.count,txt,txt))
g = match.groups()
start = ".".join(g[0:4])
@ -123,4 +123,3 @@ class PGZip(TextBase):
def close(self):
self.zfd.close()

View File

@ -21,7 +21,7 @@ class GTKConfig(gtk.Dialog):
# List source
label = gtk.Label()
label.set_markup('<b>Blocklist URL</b>')
label.set_markup('<b>' + _("Blocklist URL") + '</b>')
self.url = gtk.Entry()
ls = gtk.ListStore(gobject.TYPE_STRING, # Long name
@ -46,7 +46,7 @@ class GTKConfig(gtk.Dialog):
self.vbox.pack_start(hbox)
# Load on start
self.load_on_start = gtk.CheckButton("Download on start")
self.load_on_start = gtk.CheckButton(_("Download on start"))
self.vbox.pack_start(self.load_on_start)
self.connect('response', self.ok)
@ -100,7 +100,7 @@ class GTKProgress(gtk.Dialog):
self.vbox.set_spacing(6)
label = gtk.Label()
label.set_markup('<b>Loading and installing blocklist</b>')
label.set_markup('<b>' + _("Loading and installing blocklist") + '</b>')
self.vbox.pack_start(label)
self.progress = gtk.ProgressBar()
@ -112,7 +112,7 @@ class GTKProgress(gtk.Dialog):
self.hide_all()
def start_download(self):
self.progress.set_text("Downloading")
self.progress.set_text(_("Downloading"))
self.progress.set_fraction(0.0)
self.update()
@ -123,7 +123,7 @@ class GTKProgress(gtk.Dialog):
self.update()
def start_import(self):
self.progress.set_text("Importing")
self.progress.set_text(_("Importing"))
self.progress.set_fraction(0.0)
self.progress.set_pulse_step(0.0075)
self.update()
@ -134,7 +134,7 @@ class GTKProgress(gtk.Dialog):
self.update()
def end_import(self):
self.progress.set_text("Complete")
self.progress.set_text(_("Complete"))
self.progress.set_fraction(1.0)
self.update()