[r21540]GrampsLocale: Add _win_bindtextdomain
Adapted from init_windows_gettext in Gramps3. Libintl-8.dll must be on the path, just like all of the other C-library dependencies. svn: r21543
This commit is contained in:
parent
1d2b143be9
commit
d01f7bf7df
@ -145,6 +145,22 @@ class GrampsLocale(object):
|
|||||||
else:
|
else:
|
||||||
self.collation = os.environ["LC_COLLATE"]
|
self.collation = os.environ["LC_COLLATE"]
|
||||||
|
|
||||||
|
def _win_bindtextdomain(self, localedomain, localedir):
|
||||||
|
"""
|
||||||
|
Help routine for loading and setting up libintl attributes
|
||||||
|
Returns libintl
|
||||||
|
"""
|
||||||
|
from ctypes import cdll
|
||||||
|
try:
|
||||||
|
libintl = cdll.LoadLibrary('libintl-8')
|
||||||
|
libintl.bindtextdomain(localedomain,
|
||||||
|
localedir.encode(sys.getfilesystemencoding()))
|
||||||
|
libintl.textdomain(localedomain)
|
||||||
|
libintl.bind_textdomain_codeset(localedomain, "UTF-8")
|
||||||
|
print("Set domain %s in %s" % (localedomain, localedir))
|
||||||
|
except WindowsError:
|
||||||
|
LOG.warning("Localization library libintl not on %PATH%, localization will be incomplete")
|
||||||
|
|
||||||
|
|
||||||
def __init_first_instance(self, localedir=None, lang=None,
|
def __init_first_instance(self, localedir=None, lang=None,
|
||||||
domain=None, language=None):
|
domain=None, language=None):
|
||||||
@ -216,6 +232,8 @@ class GrampsLocale(object):
|
|||||||
# with locale instead of gettext. Win32 doesn't support bindtextdomain.
|
# with locale instead of gettext. Win32 doesn't support bindtextdomain.
|
||||||
if not win():
|
if not win():
|
||||||
locale.bindtextdomain(self.localedomain, self.localedir)
|
locale.bindtextdomain(self.localedomain, self.localedir)
|
||||||
|
else:
|
||||||
|
self._win_bindtextdomain(self.localedomain, self.localedir)
|
||||||
|
|
||||||
self.initialized = True
|
self.initialized = True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user