[virt-manager PATCH 02/16] i18n: improve labels for disk
    Pino Toscano 
    ptoscano at redhat.com
       
    Tue Jul 14 07:41:46 UTC 2020
    
    
  
Use whole strings for the labels of disks, including the bus (if
available), and the index.
There are still generic fallbacks for the disk types not explicitly
handled.
Signed-off-by: Pino Toscano <ptoscano at redhat.com>
---
 virtManager/details/details.py | 35 ++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/virtManager/details/details.py b/virtManager/details/details.py
index 8f1e3f2c..5a2a855b 100644
--- a/virtManager/details/details.py
+++ b/virtManager/details/details.py
@@ -170,21 +170,32 @@ def _label_for_device(dev):
         if dev.device == "floppy":
             return _("Floppy %(index)d") % {"index": dev.disk_bus_index}
 
-        busstr = vmmAddHardware.disk_pretty_bus(dev.bus) or ""
+        if dev.bus:
+            busstr = vmmAddHardware.disk_pretty_bus(dev.bus)
+            if dev.device == "cdrom":
+                return _("%(bus)s CDROM %(index)d") % {
+                    "bus": busstr,
+                    "index": dev.disk_bus_index,
+                }
+            elif dev.device == "disk":
+                return _("%(bus)s Disk %(index)d") % {
+                    "bus": busstr,
+                    "index": dev.disk_bus_index,
+                }
+            return _("%(bus)s %(device)s %(index)d") % {
+                "bus": busstr,
+                "device": dev.device.capitalize(),
+                "index": dev.disk_bus_index,
+            }
 
         if dev.device == "cdrom":
-            devstr = _("CDROM")
+            return _("CDROM %(index)d") % {"index": dev.disk_bus_index}
         elif dev.device == "disk":
-            devstr = _("Disk")
-        else:
-            devstr = dev.device.capitalize()
-
-        if busstr:
-            ret = "%s %s" % (busstr, devstr)
-        else:
-            ret = devstr
-
-        return "%s %s" % (ret, dev.disk_bus_index)
+            return _("Disk %(index)d") % {"index": dev.disk_bus_index}
+        return _("%(device)s %(index)d") % {
+            "device": dev.device.capitalize(),
+            "index": dev.disk_bus_index,
+        }
 
     if devtype == "interface":
         if dev.macaddr:
-- 
2.26.2
    
    
More information about the virt-tools-list
mailing list