mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
feat(vrtManager): the libvirt layer's messages show in the reader's language
vrtManager's errors (some 140: a disk that does not move, a network address outside its subnet, a host device given to another VM, the disks a migration cannot copy) were English f-strings, so no catalog could translate them, on pages or in jobs. They are marked texts with their values now; a variant that differs by a word (internal or external, running or persistent, with a subnet or without) is a whole message of its own, and a list of problems is a list of messages. OperationError reads in the active language, so the pages that show one translate it as they are; its args stay English, and so do the logs and the audit log. Host device problems and the Migrate tab's reasons a disk is not copied are messages too.
This commit is contained in:
parent
b999a3e286
commit
82b97f8ec5
21 changed files with 2371 additions and 420 deletions
|
|
@ -25,7 +25,8 @@
|
|||
</select>
|
||||
{% if disk.same_name %}<div class="form-text">{% trans "Another disk of the VM has this file name: copy them to different pools." %}</div>{% endif %}
|
||||
{% elif disk.refusal %}
|
||||
<p class="small text-danger mb-0" data-refused>{% blocktrans with reason=disk.refusal %}Cannot be copied: {{ reason }}{% endblocktrans %}</p>
|
||||
{% trans disk.refusal as reason %}
|
||||
<p class="small text-danger mb-0" data-refused>{% blocktrans %}Cannot be copied: {{ reason }}{% endblocktrans %}</p>
|
||||
{% elif pools %}
|
||||
<p class="small text-danger mb-0" data-refused>{% trans "Every pool of the destination host has a file of this name" %}</p>
|
||||
{% else %}
|
||||
|
|
|
|||
|
|
@ -2074,14 +2074,18 @@ def _host_devices(instance):
|
|||
else:
|
||||
managed = {row["address"] for row in own_pci if row["managed"] and row["next"]}
|
||||
by_address = {device["address"]: device for device in pci}
|
||||
# the problems in the page's language (vrtManager.nodedevs gives messages)
|
||||
def shown(problems):
|
||||
return [util.render(m["text"], m["values"], _) for m in problems]
|
||||
|
||||
for device in pci:
|
||||
device["problems"] = pci_problems(instance.name, device, by_address, managed | {device["address"]})
|
||||
device["problems"] = shown(pci_problems(instance.name, device, by_address, managed | {device["address"]}))
|
||||
if device["address"] in {row["address"] for row in own_pci}:
|
||||
device["problems"].append(_("The VM has it"))
|
||||
for device in usb:
|
||||
address = (device["bus"], device["device"]) if device["same_model"] else None
|
||||
device["selector"] = (*device["model"], address)
|
||||
device["problems"] = hostdev_problems(instance.name, pci, [device], set(), [device["selector"]])
|
||||
device["problems"] = shown(hostdev_problems(instance.name, pci, [device], set(), [device["selector"]]))
|
||||
if instance.name in device["vms"]:
|
||||
device["problems"].append(_("The VM has it"))
|
||||
return pci, usb
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue