[virt-manager PATCH 06/21] i18n: improve labels for serial/parallel/console

Pino Toscano ptoscano at redhat.com
Mon Jul 13 08:25:44 UTC 2020


Split the handling of serial, parallel, and console in their own cases,
as the common code is less than the non-common one.

Use separate strings in case the port number is available to avoid
string puzzles.

Signed-off-by: Pino Toscano <ptoscano at redhat.com>
---
 virtManager/details/details.py | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/virtManager/details/details.py b/virtManager/details/details.py
index 791a5ae1..6911a0bd 100644
--- a/virtManager/details/details.py
+++ b/virtManager/details/details.py
@@ -201,16 +201,20 @@ def _label_for_device(dev):
             return _("Keyboard")
         return _("Input")
 
-    if devtype in ["serial", "parallel", "console"]:
-        if devtype == "serial":
-            label = _("Serial")
-        elif devtype == "parallel":
-            label = _("Parallel")
-        elif devtype == "console":
-            label = _("Console")
+    if devtype == "serial":
         if dev.target_port is not None:
-            label += " %s" % (int(dev.target_port) + 1)
-        return label
+            return _("Serial %(num)d") % {"num": int(dev.target_port) + 1}
+        return _("Serial")
+
+    if devtype == "parallel":
+        if dev.target_port is not None:
+            return _("Parallel %(num)d") % {"num": int(dev.target_port) + 1}
+        return _("Parallel")
+
+    if devtype == "console":
+        if dev.target_port is not None:
+            return _("Console %(num)d") % {"num": int(dev.target_port) + 1}
+        return _("Console")
 
     if devtype == "channel":
         name = vmmAddHardware.char_pretty_channel_name(dev.target_name)
-- 
2.26.2




More information about the virt-tools-list mailing list