Pass UN-i18ned messages through to add_menu_action and add_button so
authorAndrew Flegg <andrew@bleb.org>
Sat, 12 Dec 2009 23:33:58 +0000 (23:33 +0000)
committerAndrew Flegg <andrew@bleb.org>
Sat, 12 Dec 2009 23:33:58 +0000 (23:33 +0000)
that they can be used to identify the methods to call. gettext is now
called *within* those methods. MB#5834

package/src/gui.py
package/src/wimpworks.py

index 1d96731..bf839c0 100755 (executable)
@@ -28,10 +28,10 @@ class HermesGUI(WimpWorks):
     self.set_background('background.png')
     
     layout = wimpworks.HildonMainScreenLayout(offset = 0.8, container = self)
-    layout.add_button(_('Retrieve'), _("Get contacts' missing info"))
-    layout.add_button(_('Refresh'), _("Update contacts' info"))
+    layout.add_button('Retrieve', _("Get contacts' missing info"))
+    layout.add_button('Refresh', _("Update contacts' info"))
 
-    self.add_menu_action(_("Accounts"))
+    self.add_menu_action("Accounts")
     self.menu.show_all()
 
   
index 6e887d8..cb8d37b 100644 (file)
@@ -3,6 +3,7 @@
 # ~~~~~~~~~~~~~~~~~~~~~~                Released under the Artistic Licence.
 #                                       http://www.bleb.org/
 
+import gettext
 import gtk, gobject
 import re
 import thread
@@ -104,7 +105,11 @@ class WimpWorks:
   def add_menu_action(self, title, window = None):
     '''Add a menu action to the given (or main) window. Once add_menu_action()
        has been called with all the properties, 'self.menu.show_all()' should be
-       called.'''
+       called.
+
+       @param title The label of the action, and used to compute the callback
+                    method. This should be the UN-i18n version: gettext is used
+                    on the value.'''
 
     if not window:
       window = self.main_window
@@ -117,7 +122,7 @@ class WimpWorks:
         raise Exception("Menu needs to be created, and no Hildon present")
         
     button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
-    button.set_label(title)
+    button.set_label(_(title))
     button.connect("clicked", self.callback, title)
     self.menu.append(button)
 
@@ -263,14 +268,15 @@ class HildonMainScreenLayout():
          the button, a method of the name 'do_title' will be invoked on the
          main class.
          
-         @param title Value of the button, and used to derive the callback method.
+         @param title Value of the button, and used to derive the callback method. This
+                      should be the UN-i18n version: gettext is used on the value.
          @param subtitle An optional subtitle containing more information.'''
 
       if _have_hildon:         
         button = hildon.Button(gtk.HILDON_SIZE_THUMB_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL,
                                title = title, value = subtitle)
       else:
-        button = gtk.Button(label = title)
+        button = gtk.Button(label = _(title))
 
       button.set_property('width-request', 250)
       button.connect('clicked', self._container.callback, title)