mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
virsh-domain-event: Make 'virshEventTrayChangePrint' translation friendly
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@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
9dc2a41f1e
commit
4c531e0130
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user