Move the translation initialisation to an earlier stage, SL #3654

Must be done early, some activities set translations globally. Remove
the support for the langpackdir.

Signed-off-by: Simon Schampijer <simon@laptop.org>
This commit is contained in:
Simon Schampijer 2012-06-04 17:45:30 +02:00
parent cd9a2b4501
commit 6330204e91
3 changed files with 9 additions and 16 deletions

View File

@ -26,6 +26,8 @@ import dbus.service
import dbus.glib import dbus.glib
from sugar3.activity import activityhandle from sugar3.activity import activityhandle
from sugar3.activity import i18n
import sugar3
from sugar3.bundle.activitybundle import ActivityBundle from sugar3.bundle.activitybundle import ActivityBundle
from sugar3 import logger from sugar3 import logger
@ -97,6 +99,12 @@ def main():
os.environ['SUGAR_BUNDLE_NAME'] = bundle.get_name() os.environ['SUGAR_BUNDLE_NAME'] = bundle.get_name()
os.environ['SUGAR_BUNDLE_VERSION'] = str(bundle.get_activity_version()) 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) splitted_module = args[0].rsplit('.', 1)
module_name = splitted_module[0] module_name = splitted_module[0]
class_name = splitted_module[1] class_name = splitted_module[1]

View File

@ -73,10 +73,8 @@ from telepathy.interfaces import CHANNEL, \
from telepathy.constants import CONNECTION_HANDLE_TYPE_CONTACT from telepathy.constants import CONNECTION_HANDLE_TYPE_CONTACT
from telepathy.constants import CONNECTION_HANDLE_TYPE_ROOM from telepathy.constants import CONNECTION_HANDLE_TYPE_ROOM
import sugar3
from sugar3 import util from sugar3 import util
from sugar3.presence import presenceservice from sugar3.presence import presenceservice
from sugar3.activity import i18n
from sugar3.activity.activityservice import ActivityService from sugar3.activity.activityservice import ActivityService
from sugar3.graphics import style from sugar3.graphics import style
from sugar3.graphics.window import Window from sugar3.graphics.window import Window
@ -259,12 +257,6 @@ class Activity(Window, Gtk.Container):
""" """
# Stuff that needs to be done early # 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') icons_path = os.path.join(get_bundle_path(), 'icons')
Gtk.IconTheme.get_default().append_search_path(icons_path) Gtk.IconTheme.get_default().append_search_path(icons_path)
@ -322,7 +314,7 @@ class Activity(Window, Gtk.Container):
self._session.connect('quit', self.__session_quit_cb) self._session.connect('quit', self.__session_quit_cb)
accel_group = Gtk.AccelGroup() accel_group = Gtk.AccelGroup()
self.set_data('sugar-accel-group', accel_group) self.sugar_accel_group = accel_group
self.add_accel_group(accel_group) self.add_accel_group(accel_group)
self._bus = ActivityService(self) self._bus = ActivityService(self)

View File

@ -17,8 +17,6 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA. # Boston, MA 02111-1307, USA.
from gi.repository import GConf
from gettext import gettext from gettext import gettext
import locale import locale
import os import os
@ -135,11 +133,6 @@ def get_locale_path(bundle_id):
if 'SUGAR_LOCALEDIR' in os.environ: if 'SUGAR_LOCALEDIR' in os.environ:
candidate_dirs[os.environ['SUGAR_LOCALEDIR']] = 2 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
candidate_dirs[os.path.join(sys.prefix, 'share', 'locale')] = 0 candidate_dirs[os.path.join(sys.prefix, 'share', 'locale')] = 0
for candidate_dir in candidate_dirs.keys(): for candidate_dir in candidate_dirs.keys():