Remove construction of the event string from sub-strings marked as
translatable. Without context it's impossible to translate it correctly.
This slightly increases verbosity of the code but actually makes it more
readable as everything is inline.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
tools/virsh-domain-event.c | 36 ++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/tools/virsh-domain-event.c b/tools/virsh-domain-event.c
index a8a321590c..c522d79dd7 100644
--- a/tools/virsh-domain-event.c
+++ b/tools/virsh-domain-event.c
@@ -254,20 +254,6 @@ virshDomainEventDiskChangeToString(int reason)
return str ? _(str) : _("unknown");
}
-VIR_ENUM_DECL(virshDomainEventTrayChange);
-VIR_ENUM_IMPL(virshDomainEventTrayChange,
- VIR_DOMAIN_EVENT_TRAY_CHANGE_LAST,
- N_("opened"),
- N_("closed"));
-
-static const char *
-virshDomainEventTrayChangeToString(int reason)
-{
- const char *str = virshDomainEventTrayChangeTypeToString(reason);
- return str ? _(str) : _("unknown");
-}
-
-
struct virshDomainEventCallback {
const char *name;
virConnectDomainEventGenericCallback cb;
@@ -511,13 +497,23 @@ virshEventTrayChangePrint(virConnectPtr conn G_GNUC_UNUSED,
int reason,
void *opaque)
{
- g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
+ switch ((virDomainEventTrayChangeReason) reason) {
+ case VIR_DOMAIN_EVENT_TRAY_CHANGE_OPEN:
+ virshEventPrintf(opaque, _("event 'tray-change' for domain
'%1$s' disk %2$s: opened\n"),
+ virDomainGetName(dom), alias);
+ break;
- virBufferAsprintf(&buf, _("event 'tray-change' for domain
'%1$s' disk %2$s: %3$s\n"),
- virDomainGetName(dom),
- alias,
- virshDomainEventTrayChangeToString(reason));
- virshEventPrint(opaque, &buf);
+ case VIR_DOMAIN_EVENT_TRAY_CHANGE_CLOSE:
+ virshEventPrintf(opaque, _("event 'tray-change' for domain
'%1$s' disk %2$s: closed\n"),
+ virDomainGetName(dom), alias);
+ break;
+
+ case VIR_DOMAIN_EVENT_TRAY_CHANGE_LAST:
+ default:
+ virshEventPrintf(opaque, _("event 'tray-change' for domain
'%1$s' disk %2$s: unknown\n"),
+ virDomainGetName(dom), alias);
+ break;
+ }
}
static void
--
2.39.2