From b0302e6fabbac3b0a6bd8f1b3b39f10eb09e14d3 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 7 May 2009 01:44:42 +0100 Subject: [PATCH] split out translation support into an separate file so it can be more correctly included everywhere --- terminator | 11 +---------- terminatorlib/__init__.py | 19 +++++++++++++++++++ terminatorlib/config.py | 2 ++ terminatorlib/configfile.py | 1 + terminatorlib/encoding.py | 2 ++ terminatorlib/prefs_profile.py | 1 + terminatorlib/terminator.py | 1 + terminatorlib/terminatorterm.py | 3 +++ terminatorlib/translation.py | 32 ++++++++++++++++++++++++++++++++ 9 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 terminatorlib/translation.py diff --git a/terminator b/terminator index f3f1d5e3..650b762d 100755 --- a/terminator +++ b/terminator @@ -22,18 +22,9 @@ import os, sys from optparse import OptionParser, SUPPRESS_HELP +import terminatorlib.translation from terminatorlib.version import APP_NAME, APP_VERSION -try: - import gettext - gettext.install (APP_NAME) -except ImportError: - import __builtin__ - def dummytrans (text): - """A _ function for systems without gettext. Effectively a NOOP""" - return text - __builtin__.__dict__['_'] = dummytrans - from terminatorlib.config import dbg, err, debug import terminatorlib.config diff --git a/terminatorlib/__init__.py b/terminatorlib/__init__.py index e69de29b..21c69fda 100644 --- a/terminatorlib/__init__.py +++ b/terminatorlib/__init__.py @@ -0,0 +1,19 @@ +#!/usr/bin/python +# Terminator - multiple gnome terminals in one window +# Copyright (C) 2006-2008 cmsj@tenshu.net +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 2 only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +"""Terminator by Chris Jones """ + diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 418b3b7f..8ca591c7 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -40,6 +40,8 @@ try: except ImportError: gconf = None +from terminatorlib import translation + # set this to true to enable debugging output # These should be moved somewhere better. debug = False diff --git a/terminatorlib/configfile.py b/terminatorlib/configfile.py index b6f2a8ce..f71f39f0 100644 --- a/terminatorlib/configfile.py +++ b/terminatorlib/configfile.py @@ -2,6 +2,7 @@ import re from terminatorlib.config import dbg, debug +from terminatorlib import translation def group(*choices): return '(' + '|'.join(choices) + ')' def any(*choices): return group(*choices) + '*' diff --git a/terminatorlib/encoding.py b/terminatorlib/encoding.py index 3f33f1a4..df6d7708 100644 --- a/terminatorlib/encoding.py +++ b/terminatorlib/encoding.py @@ -23,6 +23,8 @@ This list is taken from gnome-terminal's src/encoding.h and src/encoding.c """ +from terminatorlib import translation + class TerminatorEncoding: """Class to store encoding details""" encodings = [ diff --git a/terminatorlib/prefs_profile.py b/terminatorlib/prefs_profile.py index 472adcf8..e58b215c 100644 --- a/terminatorlib/prefs_profile.py +++ b/terminatorlib/prefs_profile.py @@ -3,6 +3,7 @@ from terminatorlib.config import dbg,err,Defaults,TerminatorConfValuestoreRC from terminatorlib.keybindings import TerminatorKeybindings,Modifier from terminatorlib.version import APP_NAME, APP_VERSION +from terminatorlib import translation import gtk, gobject diff --git a/terminatorlib/terminator.py b/terminatorlib/terminator.py index 1dc22dd5..7fa5b4e9 100755 --- a/terminatorlib/terminator.py +++ b/terminatorlib/terminator.py @@ -30,6 +30,7 @@ from config import dbg, err, debug from terminatorlib.keybindings import TerminatorKeybindings from terminatorlib.terminatorterm import TerminatorTerm from terminatorlib.prefs_profile import ProfileEditor +from terminatorlib import translation try: import deskbar.core.keybinder as bindkey diff --git a/terminatorlib/terminatorterm.py b/terminatorlib/terminatorterm.py index 38d6d405..88a1307c 100755 --- a/terminatorlib/terminatorterm.py +++ b/terminatorlib/terminatorterm.py @@ -31,6 +31,9 @@ from terminatorlib.config import dbg, err, debug #import encoding list from terminatorlib.encoding import TerminatorEncoding +# import translation support +from terminatorlib import translation + # import vte-bindings try: import vte diff --git a/terminatorlib/translation.py b/terminatorlib/translation.py new file mode 100644 index 00000000..77477539 --- /dev/null +++ b/terminatorlib/translation.py @@ -0,0 +1,32 @@ +#!/usr/bin/python +# Terminator - multiple gnome terminals in one window +# Copyright (C) 2006-2008 cmsj@tenshu.net +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 2 only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +"""Terminator by Chris Jones """ + +from terminatorlib.version import APP_NAME + +try: + import gettext + gettext.install (APP_NAME) +except ImportError: + print "Using fallback _()" + import __builtin__ + def dummytrans (text): + """A _ function for systems without gettext. Effectively a NOOP""" + return text + __builtin__.__dict__['_'] = dummytrans +