GEPS008: Moved translation utilities

svn: r19903
This commit is contained in:
Nick Hall 2012-06-23 17:36:36 +00:00
parent e2a80ded2a
commit b359b16a21
14 changed files with 29 additions and 29 deletions

View File

@ -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

View File

@ -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

View File

@ -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 _
#-------------------------------------------------------------------------

View File

@ -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

View File

@ -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)

View File

@ -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, '

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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')

View File

@ -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)

View File

@ -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)

View File

@ -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)