1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 12:46:49 +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".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
catborise 2026-11-09 14:34:57 +03:00
parent 03dcb14e45
commit f6c7f8c85e
12 changed files with 41 additions and 13 deletions

View file

@ -108,7 +108,7 @@
</div>
<div class="small text-body-secondary mt-2 mb-4">
{% trans "The last 10 readings, one every 5 seconds. Memory in use leaves out the host's buffers and cache." %}
<span id="graph_state" data-url="{% url 'compute_graph' compute.id %}" data-average-over="{% trans "average over" %}" data-updated="{% trans "Updated at %(time)s." %}"
<span id="graph_state" data-url="{% url 'compute_graph' compute.id %}" data-average-over="{% trans "average over" %}" data-usage="{% trans "Usage" context "chart" %}" data-updated="{% trans "Updated at %(time)s." %}"
data-stale="{% trans "Not updated since %(time)s: the host did not answer." %}">{% trans "Waiting for the first reading." %}</span>
</div>

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"]])

Binary file not shown.

View file

@ -10005,3 +10005,15 @@ msgstr "Tüm arabirimler"
#, python-format
msgid "The VM's CPU topology has %(count)s vCPUs: change it in the XML editor to set another maximum"
msgstr "VM'nin CPU topolojisi %(count)s vCPU içeriyor: başka bir en fazla değer için onu XML düzenleyicide değiştirin"
msgctxt "chart"
msgid "Usage"
msgstr "Kullanım"
msgctxt "chart"
msgid "Usage (RSS)"
msgstr "Kullanım (RSS)"
#, python-format
msgid "%(label)s: %(vcpu)s vCPU, %(memory)s MiB, new %(disk)s GiB disk"
msgstr "%(label)s: %(vcpu)s vCPU, %(memory)s MiB, yeni %(disk)s GiB disk"

Binary file not shown.

View file

@ -9424,3 +9424,15 @@ msgstr "所有接口"
#, python-format
msgid "The VM's CPU topology has %(count)s vCPUs: change it in the XML editor to set another maximum"
msgstr "该虚拟机的 CPU 拓扑为 %(count)s 个 vCPU:要设置其他最大值,请在 XML 编辑器中修改拓扑"
msgctxt "chart"
msgid "Usage"
msgstr "使用量"
msgctxt "chart"
msgid "Usage (RSS)"
msgstr "使用量 (RSS)"
#, python-format
msgid "%(label)s: %(vcpu)s vCPU, %(memory)s MiB, new %(disk)s GiB disk"
msgstr "%(label)s:%(vcpu)s 个 vCPU,%(memory)s MiB,新建 %(disk)s GiB 磁盘"

View file

@ -52,8 +52,7 @@ function apply_preset(button) {
clear_presets();
button.setAttribute("aria-pressed", "true");
button.classList.replace("text-body", "btn-primary");
document.querySelector("#preset-status").textContent =
`${button.dataset.label}: ${button.dataset.vcpu} vCPU, ${button.dataset.memory} MiB, new ${button.dataset.disk} GiB disk`;
document.querySelector("#preset-status").textContent = button.dataset.status;
}
function clear_presets() {

View file

@ -2,14 +2,14 @@
var state = document.getElementById("graph_state");
// the seconds each CPU point averages
var cpuWindows = [];
var cpuChart = lineChart(document.getElementById("cpuChart"), "%", ["Usage"], {
var cpuChart = lineChart(document.getElementById("cpuChart"), "%", [state.dataset.usage], {
max: 100,
tooltip: function (context, text) {
var span = cpuWindows[context.dataIndex];
return span ? text + ' (' + state.dataset.averageOver + ' ' + span + ' s)' : text;
},
});
var memChart = lineChart(document.getElementById("memChart"), "GB", ["Usage"]);
var memChart = lineChart(document.getElementById("memChart"), "GB", [state.dataset.usage]);
var cpuNow = document.getElementById("cpu_now");
var memNow = document.getElementById("mem_now");
var lastUpdate = "–";

View file

@ -21,23 +21,23 @@
stats_poll.start();
return;
}
var cpuChart = lineChart(document.getElementById("cpuChart"), "%", ["Usage"], {
var cpuChart = lineChart(document.getElementById("cpuChart"), "%", [pane.dataset.usage], {
max: 100,
tooltip: function (context, text) {
var span = cpuWindows[context.dataIndex];
return span ? text + ' (' + pane.dataset.averageOver + ' ' + span + ' s)' : text;
},
});
var memChart = lineChart(document.getElementById("memChart"), "MiB", ["Usage (RSS)"]);
var memChart = lineChart(document.getElementById("memChart"), "MiB", [pane.dataset.usageRss]);
var diskChart = {};
pane.querySelectorAll("canvas[data-disk]").forEach(function (canvas) {
diskChart[canvas.dataset.disk] = lineChart(canvas, "MB/s", ["Read", "Write"]);
diskChart[canvas.dataset.disk] = lineChart(canvas, "MB/s", [pane.dataset.read, pane.dataset.write]);
});
// two NICs with one MAC (a misconfiguration) share the first one's chart
var netChart = {};
pane.querySelectorAll("canvas[data-mac]").forEach(function (canvas) {
var mac = canvas.dataset.mac;
netChart[mac] = netChart[mac] || lineChart(canvas, "Mbit/s", ["Inbound", "Outbound"]);
netChart[mac] = netChart[mac] || lineChart(canvas, "Mbit/s", [pane.dataset.in, pane.dataset.out]);
});
// the first point at once, then every 5 s like the host graph