gettext-ify ImapFetcher and GuiImapFetcher

This commit is contained in:
steffen123 2010-08-13 04:48:06 +02:00
parent d1bb8defc8
commit 3dac606b4f
2 changed files with 17 additions and 13 deletions

View File

@ -34,18 +34,18 @@ class GuiImapFetcher (threading.Thread):
self.buttonsHBox = gtk.HBox() self.buttonsHBox = gtk.HBox()
self.mainVBox.pack_end(self.buttonsHBox, expand=False) self.mainVBox.pack_end(self.buttonsHBox, expand=False)
label=gtk.Label("To cancel just close this tab.") label=gtk.Label(_("To cancel just close this tab."))
self.buttonsHBox.add(label) self.buttonsHBox.add(label)
self.saveButton = gtk.Button("_Save") self.saveButton = gtk.Button(_("_Save"))
self.saveButton.connect('clicked', self.saveClicked) self.saveButton.connect('clicked', self.saveClicked)
self.buttonsHBox.add(self.saveButton) self.buttonsHBox.add(self.saveButton)
self.importAllButton = gtk.Button("_Import All") self.importAllButton = gtk.Button(_("_Import All"))
self.importAllButton.connect('clicked', self.importAllClicked) self.importAllButton.connect('clicked', self.importAllClicked)
self.buttonsHBox.add(self.importAllButton) self.buttonsHBox.add(self.importAllButton)
self.statusLabel=gtk.Label("If you change the config you must save before importing") self.statusLabel=gtk.Label(_("If you change the config you must save before importing"))
self.mainVBox.pack_end(self.statusLabel, expand=False, padding=4) self.mainVBox.pack_end(self.statusLabel, expand=False, padding=4)
self.passwords={} self.passwords={}
@ -88,17 +88,17 @@ class GuiImapFetcher (threading.Thread):
#def saveClicked #def saveClicked
def importAllClicked(self, widget, data=None): def importAllClicked(self, widget, data=None):
self.statusLabel.set_label("Starting import. Please wait.") #FIXME: why doesnt this one show? self.statusLabel.set_label(_("Starting import. Please wait.")) #FIXME: why doesnt this one show?
for email in self.config.emails: for email in self.config.emails:
try: try:
result=ImapFetcher.run(self.config.emails[email], self.db) result=ImapFetcher.run(self.config.emails[email], self.db)
self.statusLabel.set_label("Finished import without error.") self.statusLabel.set_label(_("Finished import without error."))
except IMAP4.error as error: except IMAP4.error as error:
if str(error)=="[AUTHENTICATIONFAILED] Authentication failed.": if str(error)=="[AUTHENTICATIONFAILED] Authentication failed.":
self.statusLabel.set_label("Login to mailserver failed: please check mailserver, username and password") self.statusLabel.set_label(_("Login to mailserver failed: please check mailserver, username and password"))
except gaierror as error: except gaierror as error:
if str(error)=="[Errno -2] Name or service not known": if str(error)=="[Errno -2] Name or service not known":
self.statusLabel.set_label("Could not connect to mailserver: check mailserver and use SSL settings and internet connectivity") self.statusLabel.set_label(_("Could not connect to mailserver: check mailserver and use SSL settings and internet connectivity"))
#def importAllClicked #def importAllClicked
def get_vbox(self): def get_vbox(self):
@ -108,7 +108,7 @@ class GuiImapFetcher (threading.Thread):
def displayConfig(self): def displayConfig(self):
box=gtk.HBox(homogeneous=True) box=gtk.HBox(homogeneous=True)
for text in ("Site", "Fetch Type", "Mailserver", "Username", "Password", "Mail Folder", "Use SSL"): for text in (_("Site"), _("Fetch Type"), _("Mailserver"), _("Username"), _("Password"), _("Mail Folder"), _("Use SSL")):
label=gtk.Label(text) label=gtk.Label(text)
box.add(label) box.add(label)
self.mainVBox.pack_start(box, expand=False) self.mainVBox.pack_start(box, expand=False)
@ -139,8 +139,8 @@ class GuiImapFetcher (threading.Thread):
box.add(entry) box.add(entry)
sslBox = gtk.combo_box_new_text() sslBox = gtk.combo_box_new_text()
sslBox.append_text("Yes") sslBox.append_text(_("Yes"))
sslBox.append_text("No") sslBox.append_text(_("No"))
sslBox.set_active(0) sslBox.set_active(0)
box.add(sslBox) box.add(sslBox)

View File

@ -22,6 +22,10 @@
from imaplib import IMAP4, IMAP4_SSL from imaplib import IMAP4, IMAP4_SSL
import PokerStarsSummary import PokerStarsSummary
import gettext
trans = gettext.translation("fpdb", localedir="locale", languages=["de_DE"])
trans.install()
def splitPokerStarsSummaries(emailText): def splitPokerStarsSummaries(emailText):
splitSummaries=emailText.split("\nPokerStars Tournament #")[1:] splitSummaries=emailText.split("\nPokerStars Tournament #")[1:]
for i in range(len(splitSummaries)): for i in range(len(splitSummaries)):
@ -39,7 +43,7 @@ def run(config, db):
else: else:
server = IMAP4(config.host) server = IMAP4(config.host)
response = server.login(config.username, config.password) #TODO catch authentication error response = server.login(config.username, config.password) #TODO catch authentication error
print "response to logging in:",response print _("response to logging in:"),response
#print "server.list():",server.list() #prints list of folders #print "server.list():",server.list() #prints list of folders
response = server.select(config.folder) response = server.select(config.folder)
@ -71,7 +75,7 @@ def run(config, db):
#print "finished importing a PS summary with result:",result #print "finished importing a PS summary with result:",result
#TODO: count results and output to shell like hand importer does #TODO: count results and output to shell like hand importer does
print "completed running Imap import, closing server connection" print _("completed running Imap import, closing server connection")
#finally: #finally:
# try: # try:
server.close() server.close()