From b08cb18c0e60d025453e798a90f8ff5973885fbc Mon Sep 17 00:00:00 2001 From: steffen123 Date: Sun, 15 Aug 2010 21:09:18 +0200 Subject: [PATCH] remove debug print; add import to Config; gettextify tables --- pyfpdb/Anonymise.py | 1 - pyfpdb/BetfairToFpdb.py | 1 - pyfpdb/Card.py | 1 - pyfpdb/Configuration.py | 12 ++++++++++++ pyfpdb/GuiBulkImport.py | 1 - pyfpdb/GuiDatabase.py | 1 - pyfpdb/GuiLogView.py | 1 - pyfpdb/HandHistoryConverter.py | 1 - pyfpdb/ImapFetcher.py | 1 - pyfpdb/Options.py | 1 - pyfpdb/Tables.py | 19 +++++++++++++++---- pyfpdb/Tables_Demo.py | 1 - pyfpdb/TourneyFilters.py | 8 ++++---- pyfpdb/fpdb.pyw | 1 - pyfpdb/windows_make_bats.py | 1 - 15 files changed, 31 insertions(+), 20 deletions(-) diff --git a/pyfpdb/Anonymise.py b/pyfpdb/Anonymise.py index 32878900..3281fa3f 100755 --- a/pyfpdb/Anonymise.py +++ b/pyfpdb/Anonymise.py @@ -25,7 +25,6 @@ import sys import locale lang=locale.getdefaultlocale()[0][0:2] -print "lang:", lang if lang=="en": def _(string): return string else: diff --git a/pyfpdb/BetfairToFpdb.py b/pyfpdb/BetfairToFpdb.py index 4a5f8b5c..07ee2612 100755 --- a/pyfpdb/BetfairToFpdb.py +++ b/pyfpdb/BetfairToFpdb.py @@ -24,7 +24,6 @@ from HandHistoryConverter import * import locale lang=locale.getdefaultlocale()[0][0:2] -print "lang:", lang if lang=="en": def _(string): return string else: diff --git a/pyfpdb/Card.py b/pyfpdb/Card.py index 6bdf3e8b..576a7b38 100755 --- a/pyfpdb/Card.py +++ b/pyfpdb/Card.py @@ -17,7 +17,6 @@ import locale lang=locale.getdefaultlocale()[0][0:2] -print "lang:", lang if lang=="en": def _(string): return string else: diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index 38b4544d..53ccaa56 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -36,6 +36,18 @@ import re import xml.dom.minidom from xml.dom.minidom import Node +import locale +lang=locale.getdefaultlocale()[0][0:2] +if lang=="en": + def _(string): return string +else: + import gettext + try: + trans = gettext.translation("fpdb", localedir="locale", languages=[lang]) + trans.install() + except IOError: + def _(string): return string + import logging, logging.config import ConfigParser diff --git a/pyfpdb/GuiBulkImport.py b/pyfpdb/GuiBulkImport.py index e7132018..9b88a12f 100755 --- a/pyfpdb/GuiBulkImport.py +++ b/pyfpdb/GuiBulkImport.py @@ -35,7 +35,6 @@ import Exceptions import locale lang=locale.getdefaultlocale()[0][0:2] -print "lang:", lang if lang=="en": def _(string): return string else: diff --git a/pyfpdb/GuiDatabase.py b/pyfpdb/GuiDatabase.py index c6cf926e..0f7cdab1 100755 --- a/pyfpdb/GuiDatabase.py +++ b/pyfpdb/GuiDatabase.py @@ -37,7 +37,6 @@ import SQL import locale lang=locale.getdefaultlocale()[0][0:2] -print "lang:", lang if lang=="en": def _(string): return string else: diff --git a/pyfpdb/GuiLogView.py b/pyfpdb/GuiLogView.py index cd901eef..f42db9e2 100755 --- a/pyfpdb/GuiLogView.py +++ b/pyfpdb/GuiLogView.py @@ -32,7 +32,6 @@ log = logging.getLogger("logview") import locale lang=locale.getdefaultlocale()[0][0:2] -print "lang:", lang if lang=="en": def _(string): return string else: diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 91ac373d..eb1d7de8 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -43,7 +43,6 @@ import Configuration import locale lang=locale.getdefaultlocale()[0][0:2] -print "lang:", lang if lang=="en": def _(string): return string else: diff --git a/pyfpdb/ImapFetcher.py b/pyfpdb/ImapFetcher.py index e43f799b..006f9894 100755 --- a/pyfpdb/ImapFetcher.py +++ b/pyfpdb/ImapFetcher.py @@ -24,7 +24,6 @@ import PokerStarsSummary import locale lang=locale.getdefaultlocale()[0][0:2] -print "lang:", lang if lang=="en": def _(string): return string else: diff --git a/pyfpdb/Options.py b/pyfpdb/Options.py index 268009c1..11ef9d43 100644 --- a/pyfpdb/Options.py +++ b/pyfpdb/Options.py @@ -21,7 +21,6 @@ from optparse import OptionParser import locale lang=locale.getdefaultlocale()[0][0:2] -print "lang:", lang if lang=="en": def _(string): return string else: diff --git a/pyfpdb/Tables.py b/pyfpdb/Tables.py index c33b1828..3ffc7d1a 100755 --- a/pyfpdb/Tables.py +++ b/pyfpdb/Tables.py @@ -29,8 +29,19 @@ import os import sys import re -# Win32 modules +import locale +lang=locale.getdefaultlocale()[0][0:2] +if lang=="en": + def _(string): return string +else: + import gettext + try: + trans = gettext.translation("fpdb", localedir="locale", languages=[lang]) + trans.install() + except IOError: + def _(string): return string +# Win32 modules if os.name == 'nt': import win32gui import win32process @@ -220,7 +231,7 @@ def discover_nt(c): tw.site = "Full Tilt" else: tw.site = "Unknown" - sys.stderr.write("Found unknown table = %s" % tw.title) + sys.stderr.write(_("Found unknown table = %s") % tw.title) if tw.site != "Unknown": eval("%s(tw)" % c.supported_sites[tw.site].decoder) else: @@ -247,7 +258,7 @@ def discover_nt_by_name(c, tablename): if 'Chat:' in titles[hwnd]: continue # Some sites (FTP? PS? Others?) have seperable or seperately constructed chat windows if ' - Table ' in titles[hwnd]: continue # Absolute table Chat window.. sigh. TODO: Can we tell what site we're trying to discover for somehow in here, so i can limit this check just to AP searches? temp = decode_windows(c, titles[hwnd], hwnd) - print "attach to window", temp + print _("attach to window"), temp return temp return None @@ -434,5 +445,5 @@ if __name__=="__main__": for t in tables.keys(): print tables[t] - print "press enter to continue" + print _("press enter to continue") sys.stdin.readline() diff --git a/pyfpdb/Tables_Demo.py b/pyfpdb/Tables_Demo.py index 45013120..f583ae48 100755 --- a/pyfpdb/Tables_Demo.py +++ b/pyfpdb/Tables_Demo.py @@ -38,7 +38,6 @@ from HandHistoryConverter import getTableTitleRe import locale lang=locale.getdefaultlocale()[0][0:2] -print "lang:", lang if lang=="en": def _(string): return string else: diff --git a/pyfpdb/TourneyFilters.py b/pyfpdb/TourneyFilters.py index 774c64c7..92b86ef3 100644 --- a/pyfpdb/TourneyFilters.py +++ b/pyfpdb/TourneyFilters.py @@ -45,9 +45,9 @@ class TourneyFilters(Filters.Filters): self.conf = db.config self.display = display - self.filterText = {'playerstitle':'Hero:', 'sitestitle':'Sites:', 'seatstitle':'Number of Players:', - 'seatsbetween':'Between:', 'seatsand':'And:', 'datestitle':'Date:', - 'tourneyTypesTitle':'Tourney Type'} + self.filterText = {'playerstitle':_('Hero:'), 'sitestitle':_('Sites:'), 'seatstitle':_('Number of Players:'), + 'seatsbetween':_('Between:'), 'seatsand':_('And:'), 'datestitle':_('Date:'), + 'tourneyTypesTitle':_('Tourney Type')} gen = self.conf.get_general_params() self.day_start = 0 @@ -102,7 +102,7 @@ class TourneyFilters(Filters.Filters): if len(result) == 1: self.siteid[site] = result[0][0] else: - print "Either 0 or more than one site matched (%s) - EEK" % site + print _("Either 0 or more than one site matched (%s) - EEK") % site # For use in date ranges. self.start_date = gtk.Entry(max=12) diff --git a/pyfpdb/fpdb.pyw b/pyfpdb/fpdb.pyw index e04d6af6..f0d73b8f 100755 --- a/pyfpdb/fpdb.pyw +++ b/pyfpdb/fpdb.pyw @@ -22,7 +22,6 @@ import Queue import locale lang=locale.getdefaultlocale()[0][0:2] -print "lang:", lang if lang=="en": def _(string): return string else: diff --git a/pyfpdb/windows_make_bats.py b/pyfpdb/windows_make_bats.py index de6a970b..39449fc7 100755 --- a/pyfpdb/windows_make_bats.py +++ b/pyfpdb/windows_make_bats.py @@ -19,7 +19,6 @@ import locale lang=locale.getdefaultlocale()[0][0:2] -print "lang:", lang if lang=="en": def _(string): return string else: