[virt-manager PATCH 03/16] i18n: fully translate "running console" messages

Pino Toscano ptoscano at redhat.com
Tue Jul 14 07:41:47 UTC 2020


Create and pass the whole strings to the internal _run_console()
function: this way there is no need to second guess what the
%(console_type) placeholder is, and the types are actually translatable.

Signed-off-by: Pino Toscano <ptoscano at redhat.com>
---
 virtinst/cli.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/virtinst/cli.py b/virtinst/cli.py
index 26da30ca..37b1f617 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -381,13 +381,11 @@ def validate_disk(dev, warn_overwrite=False):
     check_path_search(dev.conn, dev.path)
 
 
-def _run_console(domain, console_type, args):
+def _run_console(domain, message, args):
     ignore = domain
     log.debug("Running: %s", " ".join(args))
     argstr = " ".join([shlex.quote(a) for a in args])
-    print_stdout(
-        _("Running %(console_type)s console command: %(command)s") %
-        {"command": argstr, "console_type": console_type})
+    print_stdout(message % {"command": argstr})
 
     if in_testsuite():
         args = ["/bin/test"]
@@ -409,21 +407,23 @@ def _gfx_console(guest, domain):
     args = ["virt-viewer",
             "--connect", guest.conn.uri,
             "--wait", guest.name]
+    message = _("Running graphical console command: %(command)s")
 
     # Currently virt-viewer needs attaching to the local display while
     # spice gl is enabled or listen type none is used.
     if guest.has_gl() or guest.has_listen_none():
         args.append("--attach")
 
-    return _run_console(domain, "graphical", args)
+    return _run_console(domain, message, args)
 
 
 def _txt_console(guest, domain):
     args = ["virsh",
             "--connect", guest.conn.uri,
             "console", guest.name]
+    message = _("Running text console command: %(command)s")
 
-    return _run_console(domain, "text", args)
+    return _run_console(domain, message, args)
 
 
 def connect_console(guest, domain, consolecb, wait, destroy_on_exit):
-- 
2.26.2




More information about the virt-tools-list mailing list