[Sugar-devel] [PATCH sugar-toolkit-gtk3] Move the translation initialisation to an earlier stage, SL #3654

Simon Schampijer simon at schampijer.de
Mon Jun 4 12:52:21 EDT 2012


Must be done early, some activities set translations globally.
To not depend on gconf at this stage the shell does set
an env variable when reading the GConf key.

Signed-off-by: Simon Schampijer <simon at laptop.org>
---
 bin/sugar-activity              |    8 ++++++++
 src/sugar3/activity/activity.py |    6 ------
 src/sugar3/activity/i18n.py     |    8 ++------
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/bin/sugar-activity b/bin/sugar-activity
index 51ba6bf..5aef1ae 100644
--- a/bin/sugar-activity
+++ b/bin/sugar-activity
@@ -26,6 +26,8 @@ import dbus.service
 import dbus.glib
 
 from sugar3.activity import activityhandle
+from sugar3.activity import i18n
+import sugar3
 from sugar3.bundle.activitybundle import ActivityBundle
 from sugar3 import logger
 
@@ -97,6 +99,12 @@ def main():
     os.environ['SUGAR_BUNDLE_NAME'] = bundle.get_name()
     os.environ['SUGAR_BUNDLE_VERSION'] = str(bundle.get_activity_version())
 
+    # must be done early, some activities set translations globally, SL #3654
+    locale_path = i18n.get_locale_path(bundle.get_bundle_id())
+    gettext.bindtextdomain(bundle.get_bundle_id(), locale_path)
+    gettext.bindtextdomain('sugar-toolkit', sugar3.locale_path)
+    gettext.textdomain(bundle.get_bundle_id())
+
     splitted_module = args[0].rsplit('.', 1)
     module_name = splitted_module[0]
     class_name = splitted_module[1]
diff --git a/src/sugar3/activity/activity.py b/src/sugar3/activity/activity.py
index 4dea554..711b247 100644
--- a/src/sugar3/activity/activity.py
+++ b/src/sugar3/activity/activity.py
@@ -259,12 +259,6 @@ class Activity(Window, Gtk.Container):
 
         """
         # Stuff that needs to be done early
-
-        locale_path = i18n.get_locale_path(self.get_bundle_id())
-        gettext.bindtextdomain(self.get_bundle_id(), locale_path)
-        gettext.bindtextdomain('sugar-toolkit', sugar3.locale_path)
-        gettext.textdomain(self.get_bundle_id())
-
         icons_path = os.path.join(get_bundle_path(), 'icons')
         Gtk.IconTheme.get_default().append_search_path(icons_path)
 
diff --git a/src/sugar3/activity/i18n.py b/src/sugar3/activity/i18n.py
index 92acb96..f179992 100644
--- a/src/sugar3/activity/i18n.py
+++ b/src/sugar3/activity/i18n.py
@@ -17,8 +17,6 @@
 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-from gi.repository import GConf
-
 from gettext import gettext
 import locale
 import os
@@ -135,10 +133,8 @@ def get_locale_path(bundle_id):
     if 'SUGAR_LOCALEDIR' in os.environ:
         candidate_dirs[os.environ['SUGAR_LOCALEDIR']] = 2
 
-    gconf_client = GConf.Client.get_default()
-    package_dir = gconf_client.get_string('/desktop/sugar/i18n/langpackdir')
-    if package_dir is not None and package_dir is not '':
-        candidate_dirs[package_dir] = 1
+    if 'SUGAR_LANGPACKDIR' in os.environ:
+        candidate_dirs[os.environ['SUGAR_LANGPACKDIR']] = 1
 
     candidate_dirs[os.path.join(sys.prefix, 'share', 'locale')] = 0
 
-- 
1.7.10.2



More information about the Sugar-devel mailing list