03090: All strings are not shown translated

svn: r12804
This commit is contained in:
Benny Malengier 2009-07-16 12:23:51 +00:00
parent cf506f544e
commit 67f912aa2d
3 changed files with 38 additions and 9 deletions

View File

@ -24,7 +24,33 @@
Provide translation assistance
"""
from gettext import (gettext, ngettext)
import gettext
localedir = ''
localedomain = 'gramps'
def set_localedir(dir):
"""
Set the directory where locale/gettext obtains translation files
"""
global localedir
localedir = dir
def set_localedomain(name):
"""
Set the domain that locale/gettext should use
"""
global localedomain
localedomain = name
def setup_gettext():
global localedir, localedomain
gettext.bindtextdomain(localedomain, localedir)
gettext.textdomain(localedomain)
#following installs _ as a python function, we avoid this as TransUtils is
#used sometimes:
#gettext.install(localedomain, localedir, unicode=1)
def sgettext(msgid, sep='|'):
"""
@ -43,7 +69,7 @@ def sgettext(msgid, sep='|'):
:rtype: unicode
"""
msgval = gettext(msgid)
msgval = gettext.gettext(msgid)
if msgval == msgid:
sep_idx = msgid.rfind(sep)
msgval = msgid[sep_idx+1:]
@ -71,7 +97,7 @@ def sngettext(singular, plural, n, sep='|'):
:rtype: unicode
"""
msgval = ngettext(singular, plural,n)
msgval = gettext.ngettext(singular, plural,n)
if msgval == singular:
sep_idx = singular.rfind(sep)
msgval = singular[sep_idx+1:]

View File

@ -48,6 +48,7 @@ import gtk
#
#------------------------------------------------------------------------
import const
import TransUtils
#------------------------------------------------------------------------
#
@ -77,9 +78,10 @@ class Glade(gtk.Builder):
matching the file name.
:rtype: object reference
:returns: reference to the newly-created Glade instance
"""
"""
gtk.Builder.__init__(self)
self.set_translation_domain(TransUtils.localedomain)
filename_given = filename is not None
dirname_given = dirname is not None
@ -197,7 +199,6 @@ class Glade(gtk.Builder):
:rtype: object
:returns: child object
"""
if not toplevel:
toplevel = self.__toplevel
if not toplevel:

View File

@ -42,6 +42,7 @@ LOG = logging.getLogger(".")
#
#-------------------------------------------------------------------------
from Mime import mime_type_is_defined
from TransUtils import set_localedir, set_localedomain, setup_gettext
#-------------------------------------------------------------------------
#
@ -63,9 +64,10 @@ except locale.Error:
except ValueError:
pass
gettext.bindtextdomain("gramps",loc)
gettext.textdomain("gramps")
gettext.install("gramps",loc,unicode=1)
LOG.debug('Using locale:', locale.getlocale())
set_localedir(loc)
set_localedomain("gramps")
setup_gettext()
#-------------------------------------------------------------------------
#