add missing gettext imports, gettextify TournamentTracker.py
This commit is contained in:
parent
b08cb18c0e
commit
aacfb61d3b
|
@ -28,6 +28,18 @@ import time,datetime
|
|||
from copy import deepcopy
|
||||
import pprint
|
||||
|
||||
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 has been set up in fpdb.py or HUD_main.py, use their settings:
|
||||
log = logging.getLogger("parser")
|
||||
|
|
|
@ -24,6 +24,18 @@ import sys
|
|||
from HandHistoryConverter import *
|
||||
from decimal import Decimal
|
||||
|
||||
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
|
||||
|
||||
# PokerStars HH Format
|
||||
|
||||
class PokerStars(HandHistoryConverter):
|
||||
|
|
|
@ -34,8 +34,20 @@ import traceback
|
|||
|
||||
(options, argv) = Options.fpdb_options()
|
||||
|
||||
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
|
||||
|
||||
if not options.errorsToConsole:
|
||||
print "Note: error output is being diverted to fpdb-error-log.txt and HUD-error.txt. Any major error will be reported there _only_."
|
||||
print _("Note: error output is being diverted to fpdb-error-log.txt and HUD-error.txt. Any major error will be reported there _only_.")
|
||||
errorFile = open('tourneyerror.txt', 'w', 0)
|
||||
sys.stderr = errorFile
|
||||
|
||||
|
@ -96,10 +108,10 @@ class Tournament:
|
|||
self.window.show() # isn't there a better way to bring something to the front? not that GTK focus works right anyway, ever
|
||||
else:
|
||||
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||
print "tournament edit window=", self.window
|
||||
print _("tournament edit window="), self.window
|
||||
self.window.connect("delete_event", self.delete_event)
|
||||
self.window.connect("destroy", self.destroy)
|
||||
self.window.set_title("FPDB Tournament Entry")
|
||||
self.window.set_title(_("FPDB Tournament Entry"))
|
||||
self.window.set_border_width(1)
|
||||
self.window.set_default_size(480,640)
|
||||
self.window.set_resizable(True)
|
||||
|
@ -139,14 +151,14 @@ class ttracker_main(object):
|
|||
self.main_window = gtk.Window()
|
||||
self.main_window.connect("destroy", self.destroy)
|
||||
self.vb = gtk.VBox()
|
||||
self.label = gtk.Label('Closing this window will stop the Tournament Tracker')
|
||||
self.label = gtk.Label(_('Closing this window will stop the Tournament Tracker'))
|
||||
self.vb.add(self.label)
|
||||
self.addbutton = gtk.Button(label="Enter Tournament")
|
||||
self.addbutton = gtk.Button(label=_("Enter Tournament"))
|
||||
self.addbutton.connect("clicked", self.addClicked, "add tournament")
|
||||
self.vb.add(self.addbutton)
|
||||
|
||||
self.main_window.add(self.vb)
|
||||
self.main_window.set_title("FPDB Tournament Tracker")
|
||||
self.main_window.set_title(_("FPDB Tournament Tracker"))
|
||||
self.main_window.show_all()
|
||||
|
||||
def addClicked(self, widget, data): # what is "data"? i'm guessing anything i pass in after the function name in connect() but unsure because the documentation sucks
|
||||
|
@ -157,10 +169,10 @@ class ttracker_main(object):
|
|||
self.tourney_list.append(t)
|
||||
mylabel = gtk.Label("%s - %s - %s - %s - %s %s - %s - %s - %s - %s - %s" % (t.site, t.id, t.starttime, t.endtime, t.structure, t.game, t.buyin, t.fee, t.numrebuys, t.numplayers, t.prizepool))
|
||||
print "new label=", mylabel
|
||||
editbutton = gtk.Button(label="Edit")
|
||||
editbutton = gtk.Button(label=_("Edit"))
|
||||
print "new button=", editbutton
|
||||
editbutton.connect("clicked", t.openwindow)
|
||||
rebuybutton = gtk.Button(label="Rebuy")
|
||||
rebuybutton = gtk.Button(label=_("Rebuy"))
|
||||
rebuybutton.connect("clicked", t.addrebuy)
|
||||
self.vb.add(rebuybutton)
|
||||
self.vb.add(editbutton) # These should probably be put in.. a.. h-box? i don't know..
|
||||
|
@ -259,9 +271,9 @@ class ttracker_main(object):
|
|||
cards['common'] = comm_cards['common']
|
||||
except Exception, err:
|
||||
err = traceback.extract_tb(sys.exc_info()[2])[-1]
|
||||
print "db error: skipping "+str(new_hand_id)+" "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1])
|
||||
print _("db error: skipping ")+str(new_hand_id)+" "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1])
|
||||
if new_hand_id: # new_hand_id is none if we had an error prior to the store
|
||||
sys.stderr.write("Database error %s in hand %d. Skipping.\n" % (err, int(new_hand_id)))
|
||||
sys.stderr.write(_("Database error %s in hand %d. Skipping.\n") % (err, int(new_hand_id)))
|
||||
continue
|
||||
|
||||
if type == "tour": # hand is from a tournament
|
||||
|
@ -270,8 +282,8 @@ class ttracker_main(object):
|
|||
(tour_number, tab_number) = mat_obj.group(1, 2)
|
||||
temp_key = tour_number
|
||||
else: # tourney, but can't get number and table
|
||||
print "could not find tournament: skipping "
|
||||
sys.stderr.write("Could not find tournament %d in hand %d. Skipping.\n" % (int(tour_number), int(new_hand_id)))
|
||||
print _("could not find tournament: skipping")
|
||||
sys.stderr.write(_("Could not find tournament %d in hand %d. Skipping.\n") % (int(tour_number), int(new_hand_id)))
|
||||
continue
|
||||
|
||||
else:
|
||||
|
@ -294,15 +306,15 @@ class ttracker_main(object):
|
|||
# If no client window is found on the screen, complain and continue
|
||||
if type == "tour":
|
||||
table_name = "%s %s" % (tour_number, tab_number)
|
||||
sys.stderr.write("table name "+table_name+" not found, skipping.\n")
|
||||
sys.stderr.write(_("table name %s not found, skipping.\n")% table_name)
|
||||
else:
|
||||
self.create_HUD(new_hand_id, tablewindow, temp_key, max, poker_game, stat_dict, cards)
|
||||
self.db_connection.connection.rollback()
|
||||
|
||||
if __name__== "__main__":
|
||||
|
||||
sys.stderr.write("tournament tracker starting\n")
|
||||
sys.stderr.write("Using db name = %s\n" % (options.dbname))
|
||||
sys.stderr.write(_("tournament tracker starting\n"))
|
||||
sys.stderr.write(_("Using db name = %s\n") % (options.dbname))
|
||||
|
||||
# start the HUD_main object
|
||||
hm = ttracker_main(db_name = options.dbname)
|
||||
|
|
Loading…
Reference in New Issue
Block a user