1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(i18n): chart series and the preset announcement in the page's language

The VM and host charts named their series in English (Usage, Usage (RSS),
Read, Write, Inbound, Outbound) and the new-VM form announced an applied
preset as "...new N GiB disk" in English on Turkish and Chinese pages.
The texts now come from the templates: the stats tab and host overview
give the series names (disk and NIC series reuse In, Out, Read, Write of
the readings line), and each preset button carries its own announcement.
"Usage" has the context "chart": zh translated it for secrets as "used by".
This commit is contained in:
catborise 2026-11-09 14:34:57 +03:00
parent 0218a54c87
commit f92d443eec
12 changed files with 41 additions and 13 deletions

View file

@ -4,7 +4,8 @@
<div class="d-flex flex-wrap gap-2" role="group" aria-labelledby="presets-label" aria-describedby="presets_help">
{% for flavor in flavors %}
<button type="button" class="btn btn-sm border text-body focus-ring preset" aria-pressed="false"
data-label="{{ flavor.label }}" data-vcpu="{{ flavor.vcpu }}" data-memory="{{ flavor.memory }}" data-disk="{{ flavor.disk }}">
data-label="{{ flavor.label }}" data-vcpu="{{ flavor.vcpu }}" data-memory="{{ flavor.memory }}" data-disk="{{ flavor.disk }}"
data-status="{% blocktrans with label=flavor.label vcpu=flavor.vcpu memory=flavor.memory disk=flavor.disk %}{{ label }}: {{ vcpu }} vCPU, {{ memory }} MiB, new {{ disk }} GiB disk{% endblocktrans %}">
<strong>{{ flavor.label }}</strong> · {{ flavor.vcpu }} vCPU · {{ flavor.memory }} MiB · {{ flavor.disk }} GiB
</button>
{% endfor %}

View file

@ -1,7 +1,8 @@
{% load i18n %}
<div class="tab-pane" id="graphics" role="tabpanel" data-url="{% url 'instances:stats' instance.id %}"
data-average-over="{% trans "average over" %}" data-in="{% trans "In" %}" data-out="{% trans "Out" %}"
data-read="{% trans "Read" %}" data-write="{% trans "Write" %}">
data-read="{% trans "Read" %}" data-write="{% trans "Write" %}"
data-usage="{% trans "Usage" context "chart" %}" data-usage-rss="{% trans "Usage (RSS)" context "chart" %}">
<div class="card">
<div class="card-body">
<div class="d-flex flex-wrap align-items-center gap-2 mb-3">

View file

@ -204,6 +204,8 @@ class FlavorPresetTests(TestCase):
[preset] = page.xpath(f"//button[contains(@class, 'preset')][@data-label='{self.flavor.label}']")
self.assertEqual((preset.get("data-vcpu"), preset.get("data-memory"), preset.get("data-disk")), ("1", "512", "10"))
self.assertEqual((preset.get("type"), preset.get("aria-pressed")), ("button", "false"))
# what a screen reader hears when it is applied (create_instance.js), in the page's language
self.assertEqual(preset.get("data-status"), "wvc-test: 1 vCPU, 512 MiB, new 10 GiB disk")
def test_the_flavor_dialog_sits_outside_the_form(self):
_, response = render_create_page(self)

View file

@ -197,7 +197,8 @@ const fieldsets = ["new", "existing", "template"].map(s => Object.assign(new El(
all[".disk-source"] = fieldsets;
const presets = [["small", "2", "2048", "40"], ["large", "4", "8192", "80"]].map(function ([label, vcpu, memory, disk]) {
const button = new El();
Object.assign(button.dataset, {label, vcpu, memory, disk});
// status: the text the page has for it, in its language (create_presets.html)
Object.assign(button.dataset, {label, vcpu, memory, disk, status: label + " in the page's language"});
button.classes.add("text-body");
return button;
});
@ -235,7 +236,7 @@ console.log(JSON.stringify({applied, cleared: pressed()}));""")
self.assertTrue(applied["radio"])
self.assertEqual(applied["sources"][0], ["source-new", False, False])
self.assertEqual(applied["pressed"], [["false", "text-body"], ["true", "btn-primary"]])
self.assertEqual(applied["status"], "large: 4 vCPU, 8192 MiB, new 80 GiB disk")
self.assertEqual(applied["status"], "large in the page's language")
self.assertEqual(out["cleared"], [["false", "text-body"], ["false", "text-body"]])