From b359b16a2152c020502a1d8962e5f1df69571992 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Sat, 23 Jun 2012 17:36:36 +0000 Subject: [PATCH] GEPS008: Moved translation utilities svn: r19903 --- po/POTFILES.in | 2 +- src/Makefile.am | 2 -- src/gen/plug/_pluginreg.py | 2 +- src/gen/utils/Makefile.am | 4 +++- .../utils/mactrans.py} | 0 src/{TransUtils.py => gen/utils/trans.py} | 6 +++--- src/gramps.py | 18 +++++++++--------- src/gui/clipboard.py | 2 +- src/gui/glade.py | 4 ++-- src/gui/plug/quick/_quicktable.py | 2 +- src/plugins/lib/libtranslate.py | 4 ++-- src/plugins/textreport/ancestorreport.py | 4 ++-- src/plugins/textreport/detancestralreport.py | 4 ++-- src/plugins/textreport/detdescendantreport.py | 4 ++-- 14 files changed, 29 insertions(+), 29 deletions(-) rename src/{MacTransUtils.py => gen/utils/mactrans.py} (100%) rename src/{TransUtils.py => gen/utils/trans.py} (99%) diff --git a/po/POTFILES.in b/po/POTFILES.in index 09afb2779..a89d42fa3 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -4,7 +4,6 @@ # src/const.py src/gramps.py -src/TransUtils.py src/Utils.py # cli @@ -326,6 +325,7 @@ src/gen/simple/_simpletable.py src/gen/utils/alive.py src/gen/utils/lds.py src/gen/utils/place.py +src/gen/utils/trans.py # gui - GUI code src/gui/aboutdialog.py diff --git a/src/Makefile.am b/src/Makefile.am index 18ddfc40c..4a7361c46 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,8 +15,6 @@ gdirdir=$(prefix)/share/gramps gdir_PYTHON = \ const.py\ gramps.py\ - MacTransUtils.py\ - TransUtils.py\ Utils.py # Clean up all the byte-compiled files diff --git a/src/gen/plug/_pluginreg.py b/src/gen/plug/_pluginreg.py index ac62a58ac..3424ecdb0 100644 --- a/src/gen/plug/_pluginreg.py +++ b/src/gen/plug/_pluginreg.py @@ -42,7 +42,7 @@ import traceback #------------------------------------------------------------------------- from const import VERSION as GRAMPSVERSION, VERSION_TUPLE from const import IMAGE_DIR -from TransUtils import get_addon_translator +from gen.utils.trans import get_addon_translator from gen.ggettext import gettext as _ #------------------------------------------------------------------------- diff --git a/src/gen/utils/Makefile.am b/src/gen/utils/Makefile.am index e109784cf..b469a146b 100644 --- a/src/gen/utils/Makefile.am +++ b/src/gen/utils/Makefile.am @@ -15,8 +15,10 @@ pkgpython_PYTHON = \ fallback.py \ image.py \ lds.py \ + mactrans.py \ place.py \ - referent.py + referent.py \ + trans.py pkgpyexecdir = @pkgpyexecdir@/gen/utils diff --git a/src/MacTransUtils.py b/src/gen/utils/mactrans.py similarity index 100% rename from src/MacTransUtils.py rename to src/gen/utils/mactrans.py diff --git a/src/TransUtils.py b/src/gen/utils/trans.py similarity index 99% rename from src/TransUtils.py rename to src/gen/utils/trans.py index 3c9455c49..be547c9a4 100644 --- a/src/TransUtils.py +++ b/src/gen/utils/trans.py @@ -65,8 +65,8 @@ else: LOCALEDOMAIN = 'gramps' if mac(): - import MacTransUtils - MacTransUtils.mac_setup_localization(LOCALEDIR, LOCALEDOMAIN) + import mactrans + mactrans.mac_setup_localization(LOCALEDIR, LOCALEDOMAIN) else: lang = ' ' try: @@ -102,7 +102,7 @@ def setup_gettext(): except ValueError: print 'Failed to bind text domain, gtk.Builder() has no translation' - #following installs _ as a python function, we avoid this as TransUtils is + #following installs _ as a python function, we avoid this as this module is #used sometimes: #gettext.install(LOCALEDOMAIN, LOCALEDIR, unicode=1) diff --git a/src/gramps.py b/src/gramps.py index 42c68992e..30098b81e 100644 --- a/src/gramps.py +++ b/src/gramps.py @@ -48,7 +48,7 @@ from subprocess import Popen, PIPE # #------------------------------------------------------------------------- from gen.mime import mime_type_is_defined -import TransUtils +from gen.utils.trans import LOCALEDOMAIN, LOCALEDIR, setup_windows_gettext from gen.constfunc import win #------------------------------------------------------------------------- # @@ -59,8 +59,8 @@ from gen.constfunc import win #the order in which bindtextdomain on gettext and on locale is called #appears important, so we refrain from doing first all gettext. # -#TransUtils.setup_gettext() -gettext.bindtextdomain(TransUtils.LOCALEDOMAIN, TransUtils.LOCALEDIR) +#setup_gettext() +gettext.bindtextdomain(LOCALEDOMAIN, LOCALEDIR) try: locale.setlocale(locale.LC_ALL,'') except: @@ -80,8 +80,8 @@ except: # if that doesn't break Gramps under Windows # raise -gettext.textdomain(TransUtils.LOCALEDOMAIN) -gettext.install(TransUtils.LOCALEDOMAIN, localedir=None, unicode=1) #None is sys default locale +gettext.textdomain(LOCALEDOMAIN) +gettext.install(LOCALEDOMAIN, localedir=None, unicode=1) #None is sys default locale if hasattr(os, "uname"): operating_system = os.uname()[0] @@ -89,18 +89,18 @@ else: operating_system = sys.platform if win(): # Windows - TransUtils.setup_windows_gettext() + setup_windows_gettext() elif operating_system == 'FreeBSD': try: - gettext.bindtextdomain(TransUtils.LOCALEDOMAIN, TransUtils.LOCALEDIR) + gettext.bindtextdomain(LOCALEDOMAIN, LOCALEDIR) except locale.Error: print 'No translation in some gtk.Builder strings, ' elif operating_system == 'OpenBSD': pass else: # normal case try: - locale.bindtextdomain(TransUtils.LOCALEDOMAIN, TransUtils.LOCALEDIR) - #locale.textdomain(TransUtils.LOCALEDOMAIN) + locale.bindtextdomain(LOCALEDOMAIN, LOCALEDIR) + #locale.textdomain(LOCALEDOMAIN) except locale.Error: print 'No translation in some gtk.Builder strings, ' diff --git a/src/gui/clipboard.py b/src/gui/clipboard.py index 6e3683584..4d674abff 100644 --- a/src/gui/clipboard.py +++ b/src/gui/clipboard.py @@ -51,7 +51,7 @@ import gen.datehandler from gui.display import display_help from gui.managedwindow import ManagedWindow from gen.ggettext import sgettext as _ -from TransUtils import trans_objclass +from gen.utils.trans import trans_objclass from gen.constfunc import mac from gui.glade import Glade from gui.ddtargets import DdTargets diff --git a/src/gui/glade.py b/src/gui/glade.py index 069f90748..a77be9e13 100644 --- a/src/gui/glade.py +++ b/src/gui/glade.py @@ -48,7 +48,7 @@ import gtk # #------------------------------------------------------------------------ import const -import TransUtils +from gen.utils.trans import LOCALEDOMAIN #------------------------------------------------------------------------ # @@ -80,7 +80,7 @@ class Glade(gtk.Builder): :returns: reference to the newly-created Glade instance """ gtk.Builder.__init__(self) - self.set_translation_domain(TransUtils.LOCALEDOMAIN) + self.set_translation_domain(LOCALEDOMAIN) filename_given = filename is not None dirname_given = dirname is not None diff --git a/src/gui/plug/quick/_quicktable.py b/src/gui/plug/quick/_quicktable.py index 431e60b10..f9101c7bf 100644 --- a/src/gui/plug/quick/_quicktable.py +++ b/src/gui/plug/quick/_quicktable.py @@ -48,7 +48,7 @@ from gtk.gdk import ACTION_COPY #------------------------------------------------------------------------- from gen.ggettext import sgettext as _ from gen.simple import SimpleTable -from TransUtils import trans_objclass +from gen.utils.trans import trans_objclass from gen.errors import WindowActiveError from gui.widgets.multitreeview import MultiTreeView from gui.ddtargets import DdTargets diff --git a/src/plugins/lib/libtranslate.py b/src/plugins/lib/libtranslate.py index 06501dc27..ae95ea3c7 100644 --- a/src/plugins/lib/libtranslate.py +++ b/src/plugins/lib/libtranslate.py @@ -37,7 +37,7 @@ _ = gettext.gettext # GRAMPS modules # #------------------------------------------------------------------------ -import TransUtils +from gen.utils.trans import get_localedomain import gen.datehandler from gen.config import config from gen.lib.grampstype import GrampsType @@ -143,7 +143,7 @@ class Translator: else: # fallback=True will cause the translator to use English if # lang = "en" or if something goes wrong. - self.__trans = gettext.translation(TransUtils.get_localedomain(), + self.__trans = gettext.translation(get_localedomain(), languages=[lang], fallback=True) val = config.get('preferences.date-format') diff --git a/src/plugins/textreport/ancestorreport.py b/src/plugins/textreport/ancestorreport.py index ca4199ea3..5a5bab0a9 100644 --- a/src/plugins/textreport/ancestorreport.py +++ b/src/plugins/textreport/ancestorreport.py @@ -49,7 +49,7 @@ from gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle, from gen.plug.report import Report from gen.plug.report import utils as ReportUtils from gen.plug.report import MenuReportOptions -import TransUtils +from gen.utils.trans import get_available_translations from libnarrate import Narrator from libtranslate import Translator, get_language_string @@ -295,7 +295,7 @@ class AncestorOptions(MenuReportOptions): trans = EnumeratedListOption(_("Translation"), Translator.DEFAULT_TRANSLATION_STR) trans.add_item(Translator.DEFAULT_TRANSLATION_STR, _("Default")) - for language in TransUtils.get_available_translations(): + for language in get_available_translations(): trans.add_item(language, get_language_string(language)) trans.set_help(_("The translation to be used for the report.")) menu.add_option(category_name, "trans", trans) diff --git a/src/plugins/textreport/detancestralreport.py b/src/plugins/textreport/detancestralreport.py index 5be343139..062fd9e74 100644 --- a/src/plugins/textreport/detancestralreport.py +++ b/src/plugins/textreport/detancestralreport.py @@ -57,7 +57,7 @@ from gen.plug.report import MenuReportOptions import gen.datehandler from libnarrate import Narrator -import TransUtils +from gen.utils.trans import get_available_translations from libtranslate import Translator, get_language_string #------------------------------------------------------------------------ @@ -756,7 +756,7 @@ class DetAncestorOptions(MenuReportOptions): trans = EnumeratedListOption(_("Translation"), Translator.DEFAULT_TRANSLATION_STR) trans.add_item(Translator.DEFAULT_TRANSLATION_STR, _("Default")) - for language in TransUtils.get_available_translations(): + for language in get_available_translations(): trans.add_item(language, get_language_string(language)) trans.set_help(_("The translation to be used for the report.")) addopt("trans", trans) diff --git a/src/plugins/textreport/detdescendantreport.py b/src/plugins/textreport/detdescendantreport.py index ac372dfc7..6e0cfd7ae 100644 --- a/src/plugins/textreport/detdescendantreport.py +++ b/src/plugins/textreport/detdescendantreport.py @@ -61,7 +61,7 @@ from gen.plug.report import MenuReportOptions import gen.datehandler from libnarrate import Narrator -import TransUtils +from gen.utils.trans import get_available_translations from libtranslate import Translator, get_language_string #------------------------------------------------------------------------ @@ -931,7 +931,7 @@ class DetDescendantOptions(MenuReportOptions): trans = EnumeratedListOption(_("Translation"), Translator.DEFAULT_TRANSLATION_STR) trans.add_item(Translator.DEFAULT_TRANSLATION_STR, _("Default")) - for language in TransUtils.get_available_translations(): + for language in get_available_translations(): trans.add_item(language, get_language_string(language)) trans.set_help(_("The translation to be used for the report.")) add_option("trans", trans)