src/updatemanagernotifier.py
changeset 660 ea2809ad4582
parent 641 f8001bcf3d09
child 675 6dbb72c42ff4
--- a/src/updatemanagernotifier.py	Sun Nov 02 21:07:00 2008 -0800
+++ b/src/updatemanagernotifier.py	Mon Nov 03 14:04:30 2008 +0000
@@ -48,6 +48,10 @@
 import pkg.client.image as image
 import pkg.client.progress as progress
 
+# Put _() in the global namespace
+import __builtin__
+__builtin__._ = gettext.gettext
+
 START_DELAY_DEFAULT = 120
 REFRESH_PERIOD_DEFAULT = "Never"
 SHOW_NOTIFY_ICON_DEFAULT = True
@@ -76,8 +80,18 @@
 
 class UpdateManagerNotifier:
         def __init__(self):
-                # Required for pkg strings used in pkg API
-                gettext.install("pkg", "/usr/lib/locale")
+                try:
+                        self.application_dir = os.environ["UPDATE_MANAGER_NOTIFIER_ROOT"]
+                except KeyError:
+                        self.application_dir = "/"
+                locale.setlocale(locale.LC_ALL, '')
+                for module in (gettext, gtk.glade):
+                        module.bindtextdomain("pkg", self.application_dir + \
+                            "/usr/share/locale")
+                        module.textdomain("pkg")
+                # XXX Remove and use _() where self._ and self.parent._ are being used
+                self._ = gettext.gettext
+
                 self.pr = None
                 self.last_check_filename = None
                 self.time_until_next_check = 0
@@ -87,8 +101,6 @@
                 self.last_check_time = 0
                 self.refresh_period = 0
 
-                locale.setlocale(locale.LC_ALL, '')
-                self._ = gettext.gettext
                 self.client = gconf.client_get_default()
                 self.start_delay  =  self.get_start_delay()
                 # Allow gtk.main loop to start as quickly as possible