diff options
author | Marco Pesenti Gritti <mpg@redhat.com> | 2007-03-23 16:27:31 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <mpg@redhat.com> | 2007-03-23 16:27:31 (GMT) |
commit | d17e7336775de93eef81932082b9f0605ddbecbd (patch) | |
tree | 82961058cc386bf0ae09e71f6721f25228d149a4 | |
parent | a11809cccc5caba31a6fc572b5d561a167269af1 (diff) |
Add support to read linfo.
Refactor locale to actually use gettext.
-rw-r--r-- | sugar/activity/Makefile.am | 3 | ||||
-rw-r--r-- | sugar/activity/activityfactory.py | 5 | ||||
-rw-r--r-- | sugar/activity/bundle.py | 27 |
3 files changed, 33 insertions, 2 deletions
diff --git a/sugar/activity/Makefile.am b/sugar/activity/Makefile.am index 885f62e..d11a347 100644 --- a/sugar/activity/Makefile.am +++ b/sugar/activity/Makefile.am @@ -8,5 +8,4 @@ sugar_PYTHON = \ activityservice.py \ bundle.py \ bundlebuilder.py \ - bundleregistry.py \ - locale.py + bundleregistry.py diff --git a/sugar/activity/activityfactory.py b/sugar/activity/activityfactory.py index 6662ccb..7d49ffb 100644 --- a/sugar/activity/activityfactory.py +++ b/sugar/activity/activityfactory.py @@ -20,6 +20,7 @@ import logging import dbus import gobject import gtk +import gettext from sugar.presence import PresenceService from sugar.activity import bundleregistry @@ -69,6 +70,10 @@ class ActivityCreationHandler(gobject.GObject): registry = bundleregistry.get_registry() bundle = registry.get_bundle(service_name) + gettext.bindtextdomain(self._service_name, + os.path.join(bundle.get_path(), "locale")) + gettext.textdomain(self._service_name) + bus = dbus.SessionBus() proxy_obj = bus.get_object(service_name, bundle.get_object_path(), follow_name_owner_changes=True) factory = dbus.Interface(proxy_obj, "com.redhat.Sugar.ActivityFactory") diff --git a/sugar/activity/bundle.py b/sugar/activity/bundle.py index c4f8503..8dcd33c 100644 --- a/sugar/activity/bundle.py +++ b/sugar/activity/bundle.py @@ -1,4 +1,5 @@ import logging +import locale import os from ConfigParser import ConfigParser @@ -23,6 +24,10 @@ class Bundle: else: self._valid = False + linfo_path = self._get_linfo_path() + if linfo_path and os.path.isfile(linfo_path): + self._parse_locale_info(linfo_path) + def _parse_info(self, info_path): cp = ConfigParser() cp.read([info_path]) @@ -65,6 +70,28 @@ class Bundle: if cp.has_option(section, 'activity_version'): self._activity_version = int(cp.get(section, 'activity_version')) + def _parse_linfo(self, linfo_path): + cp = ConfigParser() + cp.read([linfo_path]) + + if cp.has_option('Activity', 'name'): + self._name = cp.get(section, 'name') + + def _get_linfo_path(self): + path = None + lang = locale.getdefaultlocale()[0] + if lang != None: + path = os.path.join(self._path, 'locale', lang) + if os.path.isdir(path): + path = os.path.join(self._path, 'locale', lang[:2]) + if not os.path.isdir(path): + path = None + + if path: + return os.path.join(path, 'activity.linfo') + else: + return None + def is_valid(self): return self._valid |