[meld] Update translation support for gtk.Builder
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Update translation support for gtk.Builder
- Date: Thu, 30 Sep 2010 21:41:58 +0000 (UTC)
commit 575ea4b0a20a1a0966dc881693c5b003716f6bc8
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Sep 5 06:28:58 2010 +1000
Update translation support for gtk.Builder
Under gtk.Builder, the translation mechanisms have changed. This commit
updates our translation setup to work under the new scheme, though some
quirks still remain.
For details, see:
https://bugzilla.gnome.org/show_bug.cgi?id=574520
bin/meld | 35 +++++++++++++++++++++--------------
meld/ui/gnomeglade.py | 6 ++++++
2 files changed, 27 insertions(+), 14 deletions(-)
---
diff --git a/bin/meld b/bin/meld
index 7becd9f..d082dda 100755
--- a/bin/meld
+++ b/bin/meld
@@ -16,6 +16,7 @@
### along with this program; if not, write to the Free Software
### Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+import locale
import os
import sys
@@ -65,12 +66,29 @@ import meld.paths
import gettext
_ = gettext.gettext
-gettext.bindtextdomain("meld", meld.paths.locale_dir())
-gettext.textdomain("meld")
+# Locale setting in gtk.Builder appears somewhat broken under Python. See:
+# https://bugzilla.gnome.org/show_bug.cgi?id=574520
+locale_domain = "meld"
+locale_dir = meld.paths.locale_dir()
+
+gettext.bindtextdomain(locale_domain, locale_dir)
+locale.setlocale(locale.LC_ALL,'')
+gettext.textdomain(locale_domain)
+gettext.install(locale_domain, localedir=locale_dir, unicode=True)
+
+try:
+ locale.bindtextdomain(locale_domain, locale_dir)
+except AttributeError:
+ # OS X doesn't appear to have bindtextdomain(). This will cause
+ # gtk.Builder translations to fail.
+ print "Couldn't bind the translation domain. Some translations won't work."
+except locale.Error:
+ print "Couldn't bind the translation domain. Some translations won't work."
+
# Check requirements: Python 2.4, pygtk 2.8
pyver = (2,4)
-pygtkver = (2,8,0)
+pygtkver = (2, 14, 0)
def missing_reqs(mod, ver, exception=None):
if isinstance(exception, ImportError):
@@ -96,18 +114,7 @@ try:
except (ImportError, AssertionError), e:
missing_reqs("pygtk", pygtkver, e)
-try:
- import gtk.glade
-except ImportError, e:
- missing_reqs("gtk.glade", pygtkver, e)
-
-# Ignore deprecation warnings from pygtk > 2.6
-#if gtk.pygtk_version >= (2,8,0):
-# import warnings
-# warnings.filterwarnings("ignore", category=DeprecationWarning)
-gtk.glade.bindtextdomain("meld", meld.paths.locale_dir())
-gtk.glade.textdomain("meld")
gtk.icon_theme_get_default().append_search_path(meld.paths.icon_dir())
def main():
diff --git a/meld/ui/gnomeglade.py b/meld/ui/gnomeglade.py
index 6edb64b..6047e5e 100644
--- a/meld/ui/gnomeglade.py
+++ b/meld/ui/gnomeglade.py
@@ -22,6 +22,11 @@ import sys
import gtk
import re
+
+# FIXME: duplicate defn in bin/meld
+locale_domain = "meld"
+
+
class Component(object):
"""Base class for all glade objects.
@@ -40,6 +45,7 @@ class Component(object):
"""Load the widgets from the node 'root' in file 'filename'.
"""
self.builder = gtk.Builder()
+ self.builder.set_translation_domain(locale_domain)
self.builder.add_objects_from_file(filename, [root])
self.builder.connect_signals(self)
self.widget = getattr(self, root)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]