1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 12:46:49 +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:
catborise 2026-11-03 00:05:34 +03:00
parent 1e66367bb4
commit 491819ed64
21 changed files with 2371 additions and 420 deletions

View file

@ -1,3 +1,4 @@
from django.utils.translation import gettext_noop
import base64
from libvirt import VIR_ERR_NO_STORAGE_POOL, VIR_STORAGE_XML_INACTIVE, libvirtError
@ -22,7 +23,7 @@ def value_bytes(usage_type, value):
try:
return base64.b64decode(value, validate=True)
except ValueError: # not base64, or not ASCII; the message never holds the value
raise util.OperationError("A Ceph key is base64 text, as `ceph auth get-key` prints it") from None
raise util.OperationError(gettext_noop("A Ceph key is base64 text, as `ceph auth get-key` prints it")) from None
def secrets_named(tree, path, by_usage):
@ -111,8 +112,8 @@ class wvmSecrets(wvmConnect):
if users := self.get_users(self.get_secrets_info()).get(uuid):
named = []
if users["vms"]:
named.append(f"VMs {', '.join(users['vms'])}")
named.append(util.message(gettext_noop("VMs %(names)s"), names=", ".join(users["vms"])))
if users["pools"]:
named.append(f"pools {', '.join(users['pools'])}")
raise util.OperationError(f"Secret {uuid} is used by {'; '.join(named)}; remove it from them first")
named.append(util.message(gettext_noop("pools %(names)s"), names=", ".join(users["pools"])))
raise util.OperationError(gettext_noop("Secret %(uuid)s is used by %(named)s; remove it from them first"), uuid=uuid, named=named)
secret.undefine()