From f1d2df60607b82671378efc375a0eced086899e7 Mon Sep 17 00:00:00 2001
From: Simon Schampijer <simon@schampijer.de>
Date: Mon, 4 Jun 2012 17:45:30 +0200
Subject: [PATCH sugar-toolkit-gtk3] Move the translation initialisation to an
earlier stage, SL #3654
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@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
|
b
|
import dbus.service |
26 | 26 | import dbus.glib |
27 | 27 | |
28 | 28 | from sugar3.activity import activityhandle |
| 29 | from sugar3.activity import i18n |
| 30 | import sugar3 |
29 | 31 | from sugar3.bundle.activitybundle import ActivityBundle |
30 | 32 | from sugar3 import logger |
31 | 33 | |
… |
… |
def main(): |
97 | 99 | os.environ['SUGAR_BUNDLE_NAME'] = bundle.get_name() |
98 | 100 | os.environ['SUGAR_BUNDLE_VERSION'] = str(bundle.get_activity_version()) |
99 | 101 | |
| 102 | # must be done early, some activities set translations globally, SL #3654 |
| 103 | locale_path = i18n.get_locale_path(bundle.get_bundle_id()) |
| 104 | gettext.bindtextdomain(bundle.get_bundle_id(), locale_path) |
| 105 | gettext.bindtextdomain('sugar-toolkit', sugar3.locale_path) |
| 106 | gettext.textdomain(bundle.get_bundle_id()) |
| 107 | |
100 | 108 | splitted_module = args[0].rsplit('.', 1) |
101 | 109 | module_name = splitted_module[0] |
102 | 110 | class_name = splitted_module[1] |
diff --git a/src/sugar3/activity/activity.py b/src/sugar3/activity/activity.py
index 4dea554..711b247 100644
a
|
b
|
class Activity(Window, Gtk.Container): |
259 | 259 | |
260 | 260 | """ |
261 | 261 | # Stuff that needs to be done early |
262 | | |
263 | | locale_path = i18n.get_locale_path(self.get_bundle_id()) |
264 | | gettext.bindtextdomain(self.get_bundle_id(), locale_path) |
265 | | gettext.bindtextdomain('sugar-toolkit', sugar3.locale_path) |
266 | | gettext.textdomain(self.get_bundle_id()) |
267 | | |
268 | 262 | icons_path = os.path.join(get_bundle_path(), 'icons') |
269 | 263 | Gtk.IconTheme.get_default().append_search_path(icons_path) |
270 | 264 | |
diff --git a/src/sugar3/activity/i18n.py b/src/sugar3/activity/i18n.py
index 92acb96..f179992 100644
a
|
b
|
|
17 | 17 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | 18 | # Boston, MA 02111-1307, USA. |
19 | 19 | |
20 | | from gi.repository import GConf |
21 | | |
22 | 20 | from gettext import gettext |
23 | 21 | import locale |
24 | 22 | import os |
… |
… |
def get_locale_path(bundle_id): |
135 | 133 | if 'SUGAR_LOCALEDIR' in os.environ: |
136 | 134 | candidate_dirs[os.environ['SUGAR_LOCALEDIR']] = 2 |
137 | 135 | |
138 | | gconf_client = GConf.Client.get_default() |
139 | | package_dir = gconf_client.get_string('/desktop/sugar/i18n/langpackdir') |
140 | | if package_dir is not None and package_dir is not '': |
141 | | candidate_dirs[package_dir] = 1 |
| 136 | if 'SUGAR_LANGPACKDIR' in os.environ: |
| 137 | candidate_dirs[os.environ['SUGAR_LANGPACKDIR']] = 1 |
142 | 138 | |
143 | 139 | candidate_dirs[os.path.join(sys.prefix, 'share', 'locale')] = 0 |
144 | 140 | |