From 2a69e927d224274ed7d6421fdaceb5cd0d14574d Mon Sep 17 00:00:00 2001 From: steffen123 Date: Mon, 16 Aug 2010 01:41:25 +0200 Subject: [PATCH] add more missing imports and one _() --- pyfpdb/Filters.py | 11 +++++++++++ pyfpdb/GuiGraphViewer.py | 12 ++++++++++++ pyfpdb/GuiImapFetcher.py | 12 ++++++++++++ pyfpdb/GuiPositionalStats.py | 12 ++++++++++++ pyfpdb/GuiSessionViewer.py | 12 ++++++++++++ pyfpdb/GuiTourneyPlayerStats.py | 12 ++++++++++++ pyfpdb/GuiTourneyViewer.py | 12 ++++++++++++ pyfpdb/TourneyFilters.py | 13 ++++++++++++- 8 files changed, 95 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Filters.py b/pyfpdb/Filters.py index 565b79f3..4bbc6057 100644 --- a/pyfpdb/Filters.py +++ b/pyfpdb/Filters.py @@ -30,6 +30,17 @@ import logging # logging has been set up in fpdb.py or HUD_main.py, use their settings: log = logging.getLogger("filter") +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 Configuration import Database diff --git a/pyfpdb/GuiGraphViewer.py b/pyfpdb/GuiGraphViewer.py index dcef9712..fe82aa44 100644 --- a/pyfpdb/GuiGraphViewer.py +++ b/pyfpdb/GuiGraphViewer.py @@ -42,6 +42,18 @@ except ImportError, inst: and HUD are NOT affected by this problem.""") print "ImportError: %s" % inst.args +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 fpdb_import import Database import Filters diff --git a/pyfpdb/GuiImapFetcher.py b/pyfpdb/GuiImapFetcher.py index a4e9ff4e..b9391daa 100644 --- a/pyfpdb/GuiImapFetcher.py +++ b/pyfpdb/GuiImapFetcher.py @@ -22,6 +22,18 @@ import gtk from imaplib import IMAP4 from socket import gaierror +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 ImapFetcher class GuiImapFetcher (threading.Thread): diff --git a/pyfpdb/GuiPositionalStats.py b/pyfpdb/GuiPositionalStats.py index bc758923..4963a88f 100644 --- a/pyfpdb/GuiPositionalStats.py +++ b/pyfpdb/GuiPositionalStats.py @@ -22,6 +22,18 @@ import gtk import os from time import time, strftime +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 fpdb_import import Database import Filters diff --git a/pyfpdb/GuiSessionViewer.py b/pyfpdb/GuiSessionViewer.py index 00b7631d..56df5e78 100755 --- a/pyfpdb/GuiSessionViewer.py +++ b/pyfpdb/GuiSessionViewer.py @@ -41,6 +41,18 @@ except ImportError, inst: print _("""Failed to load numpy and/or matplotlib in Session Viewer""") print _("ImportError: %s") % inst.args +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 Card import fpdb_import import Database diff --git a/pyfpdb/GuiTourneyPlayerStats.py b/pyfpdb/GuiTourneyPlayerStats.py index 7f65888f..0b90c9b3 100644 --- a/pyfpdb/GuiTourneyPlayerStats.py +++ b/pyfpdb/GuiTourneyPlayerStats.py @@ -24,6 +24,18 @@ import gtk #import sys from time import time, strftime +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 Card #import fpdb_import #import Database diff --git a/pyfpdb/GuiTourneyViewer.py b/pyfpdb/GuiTourneyViewer.py index 83781b53..3c1dd53b 100644 --- a/pyfpdb/GuiTourneyViewer.py +++ b/pyfpdb/GuiTourneyViewer.py @@ -20,6 +20,18 @@ import pygtk pygtk.require('2.0') import gtk +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 + class GuiTourneyViewer (threading.Thread): def __init__(self, config, db, sql, mainwin, debug=True): self.db = db diff --git a/pyfpdb/TourneyFilters.py b/pyfpdb/TourneyFilters.py index 92b86ef3..ddb98166 100644 --- a/pyfpdb/TourneyFilters.py +++ b/pyfpdb/TourneyFilters.py @@ -29,6 +29,17 @@ from time import gmtime, mktime, strftime, strptime import logging #logging has been set up in fpdb.py or HUD_main.py, use their settings: log = logging.getLogger("filter") +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 Configuration #import Database @@ -74,7 +85,7 @@ class TourneyFilters(Filters.Filters): self.numTourneys = int(w.get_text()) except: self.numTourneys = 0 - print "setting numTourneys:", self.numTourneys + print _("setting numTourneys:"), self.numTourneys #end def __set_num_tourneys def __toggle_box(self, widget, entry): #identical with Filters