FINALLY: this fixes translation issues with gtk.Builder on my box (ubuntu 9.10)
svn: r14253
This commit is contained in:
parent
f7aad51665
commit
e752af9ed6
9
README
9
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
|
||||
|
@ -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.
|
||||
|
@ -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()
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user