[nanny] Removing markup from translatable strings



commit 8b369452adbc4eb7f80f5572d17ad4e56573d815
Author: Claude Paroz <claude 2xlibre net>
Date:   Fri Feb 5 09:24:48 2010 +0100

    Removing markup from translatable strings

 client/common/src/DBusClient.py                |    2 +-
 client/gnome/admin/src/AdminConsole.py         |    4 ++--
 client/gnome/admin/src/ConfigureProxyDialog.py |   12 ++++++------
 client/gnome/systray/src/SystrayNanny.py       |   21 +++++++++------------
 4 files changed, 18 insertions(+), 21 deletions(-)
---
diff --git a/client/common/src/DBusClient.py b/client/common/src/DBusClient.py
index 7cc8875..2cdb6c2 100644
--- a/client/common/src/DBusClient.py
+++ b/client/common/src/DBusClient.py
@@ -75,7 +75,7 @@ class DBusClient(gobject.GObject):
         msg = gtk.MessageDialog(parent=None, flags=0,
                                 type=gtk.MESSAGE_ERROR,
                                 buttons=gtk.BUTTONS_CLOSE, message_format=None)
-        msg.set_markup(_(u"<b>NannyDaemon unavailable</b>"))
+        msg.set_markup(u"<b>%s</b>" % _(u"NannyDaemon unavailable"))
         msg.format_secondary_markup(_(u"NannyDaemon is not activated or does not work properly.\nPlease try to reactivate it."))
         ret = msg.run()
         msg.destroy()
diff --git a/client/gnome/admin/src/AdminConsole.py b/client/gnome/admin/src/AdminConsole.py
index 5a384bd..78d8c7b 100644
--- a/client/gnome/admin/src/AdminConsole.py
+++ b/client/gnome/admin/src/AdminConsole.py
@@ -42,7 +42,7 @@ class AdminConsole:
         except:
             d = gtk.MessageDialog(None, gtk.DIALOG_MODAL, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_OK)
             d.set_property("icon-name", "nanny")
-            d.set_markup(_("<b>Nanny daemon is not started</b>"))
+            d.set_markup("<b>%s</b>" % _("Nanny daemon is not started"))
             d.format_secondary_markup(_("To use the parental control, please start up the daemon."))
             d.run()
             d.destroy()
@@ -276,7 +276,7 @@ class AdminConsole:
             if self.__config_changed:
                 dialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_YES_NO)
                 dialog.set_property("icon-name", "nanny")
-                dialog.set_markup (_('<b>You have made changes</b>'))
+                dialog.set_markup ("<b>%s</b>" % _('You have made changes'))
                 dialog.format_secondary_markup (_("If you don't press the 'Apply' button, your changes will be lost.\nAre you sure?") )
                 dialog.set_default_response(gtk.RESPONSE_YES)
                 ret = dialog.run()
diff --git a/client/gnome/admin/src/ConfigureProxyDialog.py b/client/gnome/admin/src/ConfigureProxyDialog.py
index 544c72c..b3b6163 100644
--- a/client/gnome/admin/src/ConfigureProxyDialog.py
+++ b/client/gnome/admin/src/ConfigureProxyDialog.py
@@ -239,7 +239,7 @@ class ConfigureProxyDialog (gtk.Dialog):
         else:
             dlg = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK)
             dlg.set_property("icon-name", "nanny")
-            dlg.set_markup(_("<b>Error while importing list from the Internet</b>"))
+            dlg.set_markup("<b>%s</b>" % _("Error while importing list from the Internet"))
             dlg.format_secondary_markup(_("Some error has occured while downloading the list.\nPlease verify the URL and try again."))
             dlg.run()
             dlg.destroy()
@@ -250,7 +250,7 @@ class ConfigureProxyDialog (gtk.Dialog):
 
         dlg = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK)
         dlg.set_property("icon-name", "nanny")
-        dlg.set_markup(_("<b>Error while importing list from the Internet</b>"))
+        dlg.set_markup("<b>%s</b>" % _("Error while importing list from the Internet"))
         dlg.format_secondary_markup(_("Some error has occured while downloading the list.\nPlease verify the URL and try again."))
         dlg.run()
         dlg.destroy()
@@ -342,7 +342,7 @@ class ConfigureProxyDialog (gtk.Dialog):
     def __on_custom_blacklist_remove_button_clicked (self, widget, data=None):
         dlg = gtk.MessageDialog(type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_OK_CANCEL)
         dlg.set_property("icon-name", "nanny")
-        dlg.set_markup(_("<b>Are you sure you want to delete this filter?</b>"))
+        dlg.set_markup("<b>%s</b>" % _("Are you sure you want to delete this filter?"))
         dlg.format_secondary_markup(_("You will not be able to undo this action."))
         ret = dlg.run()
         dlg.destroy()
@@ -363,7 +363,7 @@ class ConfigureProxyDialog (gtk.Dialog):
     def __on_custom_whitelist_remove_button_clicked (self, widget, data=None):
         dlg = gtk.MessageDialog(type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_OK_CANCEL)
         dlg.set_property("icon-name", "nanny")
-        dlg.set_markup(_("<b>Are you sure you want to delete this filter?</b>"))
+        dlg.set_markup("<b>%s</b>" % _("Are you sure you want to delete this filter?"))
         dlg.format_secondary_markup(_("You will not be able to undo this action."))
         ret = dlg.run()
         dlg.destroy()
@@ -390,7 +390,7 @@ class ConfigureProxyDialog (gtk.Dialog):
         else:
             dlg = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK)
             dlg.set_property("icon-name", "nanny")
-            dlg.set_markup(_("<b>Error while deleting filters</b>"))
+            dlg.set_markup("<b>%s</b>" % _("Error while deleting filters"))
             dlg.format_secondary_markup(_("Some error has occured while deleting filters.\nPlease try again."))
             dlg.run()
             dlg.destroy()
@@ -401,7 +401,7 @@ class ConfigureProxyDialog (gtk.Dialog):
 
         dlg = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK)
         dlg.set_property("icon-name", "nanny")
-        dlg.set_markup(_("<b>Error while deleting filters</b>"))
+        dlg.set_markup("<b>%s</b>" % _("Error while deleting filters"))
         dlg.format_secondary_markup(_("Some error has occured while deleting filters.\nPlease try again."))
         dlg.run()
         dlg.destroy()
diff --git a/client/gnome/systray/src/SystrayNanny.py b/client/gnome/systray/src/SystrayNanny.py
index 5a929c3..a7e2bee 100644
--- a/client/gnome/systray/src/SystrayNanny.py
+++ b/client/gnome/systray/src/SystrayNanny.py
@@ -29,6 +29,7 @@ import os.path
 import gtk
 import pynotify
 import gobject
+from gettext import ngettext
 
 import nanny.client.common
 import nanny.client.gnome.systray
@@ -91,10 +92,10 @@ class SystrayNanny(gtk.StatusIcon):
                     mssg += "\n"
                 if self.times_left[app_id][1]:
                     # To translators: In x-minutes the access to <app> will be granted
-                    mssg += _("In %s the access to %s will be granted.") % (time, self.app_names[app_id])
+                    mssg += _("In %(time)s the access to %(app)s will be granted.") % {'time': time, 'app': self.app_names[app_id]}
                 else:
                     # To translators: In x-minutes the access to <app> will be denied
-                    mssg += _("In %s the access to %s will be denied.") % (time, self.app_names[app_id])
+                    mssg += _("In %(time)s the access to %(app)s will be denied.") % {'time': time, 'app': self.app_names[app_id]}
 
         if mssg_ready:
             self.__showNotification( mssg )
@@ -105,19 +106,15 @@ class SystrayNanny(gtk.StatusIcon):
         h, m = divmod(minutes, 60)
         d, h = divmod (h, 24)
 
-        time = ""
+        time_list = []
         if d > 0:
-            time += ngettext("%s day", "%s days", d) % d
-            
+            time_list.append(ngettext("%d day", "%d days", d) % d)
         if h > 0:
-            if len(time) > 0:
-                time += ", "
-            time += ngettext("%s hour", "%s hours", h) % h
-            
+            time_list.append(ngettext("%d hour", "%d hours", h) % h)
         if m > 0:
-            if len(time) > 0:
-                time += ", "
-            time += ngettext("%s minute", "%s minutes", m) % m
+            time_list.append(ngettext("%d minute", "%d minutes", m) % m)
+        # Translators: This is the separator between time strings, like '1 day, 2 hours, 3 minutes'
+        time = _(", ").join(time_list)
 
         return time
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]