diff --git a/README b/README index 298330ed8..31ca21bbd 100644 --- a/README +++ b/README @@ -10,6 +10,15 @@ The following packages *MUST* be installed in order for Gramps to work: librsvg2 (svg icon view) xdg-utils +The following package is needed for full translation of the interface +to your language: + language-pack-gnome-xx + Translation of GTK elements to your language, with + with xx your language code eg for Dutch you need + language-pack-gnome-nl. The translation of the + Gramps strings is included with the source code. + + The following packages are *STRONGLY RECOMMENDED* to be installed: GraphViz Enable creation of graphs using GraphViz engine http://www.graphviz.org diff --git a/src/TransUtils.py b/src/TransUtils.py index add5d921f..46c3870ea 100644 --- a/src/TransUtils.py +++ b/src/TransUtils.py @@ -33,6 +33,7 @@ Provide translation assistance import gettext import sys import os +import locale #------------------------------------------------------------------------- # @@ -69,11 +70,27 @@ def setup_gettext(): """ gettext.bindtextdomain(LOCALEDOMAIN, LOCALEDIR) gettext.textdomain(LOCALEDOMAIN) + try: + locale.bindtextdomain(LOCALEDOMAIN, LOCALEDIR) + 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 #used sometimes: #gettext.install(LOCALEDOMAIN, LOCALEDIR, unicode=1) - + +def setup_windows_gtk(): + """ function to decide if needed on windows + This function should be called on windows instead of locale.bindtextdomain + """ + from Utils import win + if win(): + try: + libintl = ctypes.cdll.LoadLibrary("C:\\GTK\\gtk-2.18.5\\bin\\intl.dll") + libintl.bindtextdomain(LOCALEDOMAIN, LOCALEDIR) + except: + print "Error Loading translations into gtk.builder files" + def get_localedomain(): """ Get the LOCALEDOMAIN used for the Gramps application. diff --git a/src/gramps.py b/src/gramps.py index dd4c8ad09..a0891d9e7 100644 --- a/src/gramps.py +++ b/src/gramps.py @@ -28,11 +28,11 @@ #------------------------------------------------------------------------- import sys import os -import locale import const import signal import gettext _ = gettext.gettext +import locale import logging LOG = logging.getLogger(".") @@ -50,6 +50,12 @@ import TransUtils # Load internationalization setup # #------------------------------------------------------------------------- + +#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) try: locale.setlocale(locale.LC_ALL,'C') locale.setlocale(locale.LC_ALL,'') @@ -58,8 +64,18 @@ except locale.Error: except ValueError: pass +gettext.textdomain(TransUtils.LOCALEDOMAIN) +gettext.install(TransUtils.LOCALEDOMAIN, localedir=None, unicode=1) #None is sys default locale + +try: + locale.bindtextdomain(TransUtils.LOCALEDOMAIN, TransUtils.LOCALEDIR) + #locale.textdomain(TransUtils.LOCALEDOMAIN) +except locale.Error: + print 'No translation in some gtk.Builder strings, '\ + 'call TransUtils.setup_windows_gtk ??' + LOG.debug('Using locale:', locale.getlocale()) -TransUtils.setup_gettext() + #------------------------------------------------------------------------- #