[virt-manager PATCH 2/3] i18n: create single strings for texts/messages

Pino Toscano ptoscano at redhat.com
Wed Jul 15 12:48:57 UTC 2020


Use single strings with proper placeholders for texts, so there is no
need to join together bits of translated texts.

Signed-off-by: Pino Toscano <ptoscano at redhat.com>
---
 virtManager/createvm.py          |  7 +------
 virtManager/details/snapshots.py | 30 +++++++++++++++++-------------
 virtinst/cloner.py               |  6 ++++--
 3 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/virtManager/createvm.py b/virtManager/createvm.py
index a28e05ae..ca9ca97c 100644
--- a/virtManager/createvm.py
+++ b/virtManager/createvm.py
@@ -1740,14 +1740,9 @@ class vmmCreateVM(vmmGObjectUI):
         if nettype is None:
             # No network device available
             instmethod = self._get_config_install_page()
-            methname = None
             if instmethod == INSTALL_PAGE_URL:
-                methname = "URL"
-
-            if methname:
                 return self.err.val_err(
-                            _("Network device required for %s install.") %
-                            methname)
+                            _("Network device required for URL install."))
 
         macaddr = virtinst.DeviceInterface.generate_mac(
             self.conn.get_backend())
diff --git a/virtManager/details/snapshots.py b/virtManager/details/snapshots.py
index 5fed72ec..35435d1d 100644
--- a/virtManager/details/snapshots.py
+++ b/virtManager/details/snapshots.py
@@ -453,15 +453,18 @@ class vmmSnapshotPage(vmmGObjectUI):
             if snap.is_external():
                 has_external = True
                 sortname = "3%s" % name
-                external = " (%s)" % _("External")
+                label = _("%(vm)s\n<span size='small'>VM State: "
+                          "%(state)s (External)</span>")
             else:
                 has_internal = True
-                external = ""
                 sortname = "1%s" % name
+                label = _("%(vm)s\n<span size='small'>VM State: "
+                          "%(state)s</span>")
 
-            label = "%s\n<span size='small'>%s: %s%s</span>" % (
-                (xmlutil.xml_escape(name), _("VM State"),
-                 xmlutil.xml_escape(state), external))
+            label = label % {
+                "vm": xmlutil.xml_escape(name),
+                "state": xmlutil.xml_escape(state)
+            }
             model.append([name, label, desc, snap.run_status_icon_name(),
                           sortname, snap.is_current()])
 
@@ -652,14 +655,15 @@ class vmmSnapshotPage(vmmGObjectUI):
 
         snap = snaps[0]
 
-        label = _("disk")
-        if not self.vm.is_active():
-            label = _("disk and configuration")
-
-        msg = (_("Are you sure you want to run snapshot '%(name)s'? "
-            "All %(changetype)s changes since the last snapshot was "
-            "created will be discarded.") %
-            {"name": snap.get_name(), "changetype": label})
+        if self.vm.is_active():
+            msg = _("Are you sure you want to run the snapshot '%(name)s'? "
+                    "All the disk changes since the last snapshot was created "
+                    "will be discarded.")
+        else:
+            msg = _("Are you sure you want to run the snapshot '%(name)s'? "
+                    "All the disk and configuration changes since the last "
+                    "snapshot was created will be discarded.")
+        msg = msg % {"name": snap.get_name()}
 
         result = self.err.yes_no(msg)
         if not result:
diff --git a/virtinst/cloner.py b/virtinst/cloner.py
index d3ba1bfa..4ce56683 100644
--- a/virtinst/cloner.py
+++ b/virtinst/cloner.py
@@ -160,8 +160,10 @@ class Cloner(object):
             except Exception as e:
                 log.debug("Error setting clone path.", exc_info=True)
                 raise ValueError(
-                        (_("Could not use path '%s' for cloning") % path) +
-                        (": " + str(e)))
+                    _("Could not use path '%(path)s' for cloning: %(error)s") % {
+                        "path": path,
+                        "error": str(e),
+                    })
 
         self._clone_disks = disklist
     def get_clone_paths(self):
-- 
2.26.2




More information about the virt-tools-list mailing list