auto-detect language

This commit is contained in:
steffen123 2010-08-15 20:50:49 +02:00
parent 21211a7669
commit b4317bba2a
14 changed files with 156 additions and 39 deletions

View File

@ -23,9 +23,18 @@ import HandHistoryConverter
import Configuration
import sys
import gettext
trans = gettext.translation("fpdb", localedir="locale", languages=["de_DE"])
trans.install()
import locale
lang=locale.getdefaultlocale()[0][0:2]
print "lang:", lang
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
(options, argv) = Options.fpdb_options()
config = Configuration.Config()

View File

@ -22,9 +22,18 @@ import sys
import logging
from HandHistoryConverter import *
import gettext
trans = gettext.translation("fpdb", localedir="locale", languages=["de_DE"])
trans.install()
import locale
lang=locale.getdefaultlocale()[0][0:2]
print "lang:", lang
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
# Betfair HH format

View File

@ -15,9 +15,18 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt.
import gettext
trans = gettext.translation("fpdb", localedir="locale", languages=["de_DE"])
trans.install()
import locale
lang=locale.getdefaultlocale()[0][0:2]
print "lang:", lang
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
# From fpdb_simple
card_map = { "0": 0, "2": 2, "3" : 3, "4" : 4, "5" : 5, "6" : 6, "7" : 7, "8" : 8,

View File

@ -33,9 +33,18 @@ import fpdb_import
import Configuration
import Exceptions
import gettext
trans = gettext.translation("fpdb", localedir="locale", languages=["de_DE"])
trans.install()
import locale
lang=locale.getdefaultlocale()[0][0:2]
print "lang:", lang
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 GuiBulkImport():

View File

@ -35,9 +35,18 @@ import Exceptions
import Database
import SQL
import gettext
trans = gettext.translation("fpdb", localedir="locale", languages=["de_DE"])
trans.install()
import locale
lang=locale.getdefaultlocale()[0][0:2]
print "lang:", lang
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 GuiDatabase:

View File

@ -30,9 +30,18 @@ import logging
# logging has been set up in fpdb.py or HUD_main.py, use their settings:
log = logging.getLogger("logview")
import gettext
trans = gettext.translation("fpdb", localedir="locale", languages=["de_DE"])
trans.install()
import locale
lang=locale.getdefaultlocale()[0][0:2]
print "lang:", lang
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
MAX_LINES = 100000 # max lines to display in window
EST_CHARS_PER_LINE = 150 # used to guesstimate number of lines in log file

View File

@ -60,9 +60,18 @@ elif os.name == 'nt':
#import Tables
import Hud
import gettext
trans = gettext.translation("fpdb", localedir="locale", languages=["de_DE"])
trans.install()
import locale
lang=locale.getdefaultlocale()[0][0:2]
print "lang:", lang
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
# get config and set up logger
c = Configuration.Config(file=options.config, dbname=options.dbname)

View File

@ -41,9 +41,18 @@ import Hand
from Exceptions import FpdbParseError
import Configuration
#import gettext
#trans = gettext.translation("fpdb", localedir="locale", languages=["de_DE"])
#trans.install()
import locale
lang=locale.getdefaultlocale()[0][0:2]
print "lang:", lang
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 pygtk
import gtk

View File

@ -22,9 +22,18 @@
from imaplib import IMAP4, IMAP4_SSL
import PokerStarsSummary
import gettext
trans = gettext.translation("fpdb", localedir="locale", languages=["de_DE"])
trans.install()
import locale
lang=locale.getdefaultlocale()[0][0:2]
print "lang:", lang
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
def splitPokerStarsSummaries(emailText):
splitSummaries=emailText.split("\nPokerStars Tournament #")[1:]

View File

@ -19,9 +19,18 @@ import sys
from optparse import OptionParser
# http://docs.python.org/library/optparse.html
import gettext
trans = gettext.translation("fpdb", localedir="locale", languages=["de_DE"])
trans.install()
import locale
lang=locale.getdefaultlocale()[0][0:2]
print "lang:", lang
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
def fpdb_options():

View File

@ -36,9 +36,18 @@ import gobject
import Configuration
from HandHistoryConverter import getTableTitleRe
import gettext
trans = gettext.translation("fpdb", localedir="locale", languages=["de_DE"])
trans.install()
import locale
lang=locale.getdefaultlocale()[0][0:2]
print "lang:", lang
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
# get the correct module for the current os
if os.name == 'posix':

View File

@ -20,9 +20,18 @@ import sys
import re
import Queue
import gettext
trans = gettext.translation("fpdb", localedir="locale", languages=["de_DE"])
trans.install()
import locale
lang=locale.getdefaultlocale()[0][0:2]
print "lang:", lang
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 path is set to use an old version of python look for a new one:
# (does this work in linux?)

View File

@ -17,9 +17,18 @@
# create .bat scripts in windows to try out different gtk dirs
import gettext
trans = gettext.translation("fpdb", localedir="locale", languages=["de_DE"])
trans.install()
import locale
lang=locale.getdefaultlocale()[0][0:2]
print "lang:", lang
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
try: