From 3dac606b4f7cb796f3ad7c198726832ff7a291ea Mon Sep 17 00:00:00 2001 From: steffen123 Date: Fri, 13 Aug 2010 04:48:06 +0200 Subject: [PATCH] gettext-ify ImapFetcher and GuiImapFetcher --- pyfpdb/GuiImapFetcher.py | 22 +++++++++++----------- pyfpdb/ImapFetcher.py | 8 ++++++-- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/pyfpdb/GuiImapFetcher.py b/pyfpdb/GuiImapFetcher.py index 84af7d65..a4e9ff4e 100644 --- a/pyfpdb/GuiImapFetcher.py +++ b/pyfpdb/GuiImapFetcher.py @@ -34,18 +34,18 @@ class GuiImapFetcher (threading.Thread): self.buttonsHBox = gtk.HBox() 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.saveButton = gtk.Button("_Save") + self.saveButton = gtk.Button(_("_Save")) self.saveButton.connect('clicked', self.saveClicked) self.buttonsHBox.add(self.saveButton) - self.importAllButton = gtk.Button("_Import All") + self.importAllButton = gtk.Button(_("_Import All")) self.importAllButton.connect('clicked', self.importAllClicked) 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.passwords={} @@ -88,17 +88,17 @@ class GuiImapFetcher (threading.Thread): #def saveClicked 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: try: 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: 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: 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 get_vbox(self): @@ -108,7 +108,7 @@ class GuiImapFetcher (threading.Thread): def displayConfig(self): 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) box.add(label) self.mainVBox.pack_start(box, expand=False) @@ -139,8 +139,8 @@ class GuiImapFetcher (threading.Thread): box.add(entry) sslBox = gtk.combo_box_new_text() - sslBox.append_text("Yes") - sslBox.append_text("No") + sslBox.append_text(_("Yes")) + sslBox.append_text(_("No")) sslBox.set_active(0) box.add(sslBox) diff --git a/pyfpdb/ImapFetcher.py b/pyfpdb/ImapFetcher.py index 97dbf3de..ee267cf9 100755 --- a/pyfpdb/ImapFetcher.py +++ b/pyfpdb/ImapFetcher.py @@ -22,6 +22,10 @@ from imaplib import IMAP4, IMAP4_SSL import PokerStarsSummary +import gettext +trans = gettext.translation("fpdb", localedir="locale", languages=["de_DE"]) +trans.install() + def splitPokerStarsSummaries(emailText): splitSummaries=emailText.split("\nPokerStars Tournament #")[1:] for i in range(len(splitSummaries)): @@ -39,7 +43,7 @@ def run(config, db): else: server = IMAP4(config.host) 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 response = server.select(config.folder) @@ -71,7 +75,7 @@ def run(config, db): #print "finished importing a PS summary with result:",result #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: # try: server.close()