* [pve-devel] [PATCH widget-toolkit 1/1] utils: use ngettext for number of CPUs
@ 2026-01-28 8:56 Maximiliano Sandoval
2026-01-28 8:56 ` [pve-devel] [PATCH proxmox-datacenter-manager 1/1] use ngettext for the " Maximiliano Sandoval
2026-01-28 9:29 ` [pve-devel] [PATCH widget-toolkit 1/1] utils: use ngettext for " Maximiliano Sandoval
0 siblings, 2 replies; 3+ messages in thread
From: Maximiliano Sandoval @ 2026-01-28 8:56 UTC (permalink / raw)
To: pve-devel
Note that it is up to the translator to translate the singular using
{1}, for example one could translate it as "{0}% of one CPU" in British
English.
The string will be extracted as:
```
#. TRANSLATORS: For example "5% of 24 CPUs"
#: proxmox-widget-toolkit/src/Utils.js:1123
#, javascript-format
msgid "{0}% of {1} CPU"
msgid_plural "{0}% of {1} CPUs"
msgstr[0] "{0}% de {1} CPU"
msgstr[1] "{0}% de {1} CPUs"
```
xgettext has some understanding of javascript and mistakenly thinks that
'%' will reference a variable, hence the javascript-format hint, but
this is a pre-existing issue.
[1] https://www.gnu.org/software/gettext/manual/html_node/javascript_002dformat.html
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
src/Utils.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/Utils.js b/src/Utils.js
index 5457ffa..ed51ce5 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -1118,7 +1118,8 @@ Ext.define('Proxmox.Utils', {
render_cpu_usage: function (val, max) {
return Ext.String.format(
- `${gettext('{0}% of {1}')} ${gettext('CPU(s)')}`,
+ // TRANSLATORS: For example "5% of 24 CPUs"
+ ngettext('{0}% of {1} CPU', '{0}% of {1} CPUs', max),
(val * 100).toFixed(2),
max,
);
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] [PATCH proxmox-datacenter-manager 1/1] use ngettext for the number of CPUs
2026-01-28 8:56 [pve-devel] [PATCH widget-toolkit 1/1] utils: use ngettext for number of CPUs Maximiliano Sandoval
@ 2026-01-28 8:56 ` Maximiliano Sandoval
2026-01-28 9:29 ` [pve-devel] [PATCH widget-toolkit 1/1] utils: use ngettext for " Maximiliano Sandoval
1 sibling, 0 replies; 3+ messages in thread
From: Maximiliano Sandoval @ 2026-01-28 8:56 UTC (permalink / raw)
To: pve-devel
This is following changes in proxmox-widget-toolkit.
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
ui/src/pve/lxc/overview.rs | 4 ++--
ui/src/pve/qemu/overview.rs | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/ui/src/pve/lxc/overview.rs b/ui/src/pve/lxc/overview.rs
index 8c0196b3..2764ffa2 100644
--- a/ui/src/pve/lxc/overview.rs
+++ b/ui/src/pve/lxc/overview.rs
@@ -292,10 +292,10 @@ impl yew::Component for LxcanelComp {
status_row(
tr!("CPU usage"),
"fa-cpu",
+ // TRANSLATORS: For example "5% of 24 CPUs"
tr!(
- "{0}% of {1} CPU(s)",
+ "{0}% of {n} CPU" | "{0}% of {n} CPUs" % status.cpus.unwrap_or_default(),
format!("{:.2}", cpu * 100.0),
- status.cpus.unwrap_or_default()
),
)
.value(cpu as f32),
diff --git a/ui/src/pve/qemu/overview.rs b/ui/src/pve/qemu/overview.rs
index 6e601d00..7766580a 100644
--- a/ui/src/pve/qemu/overview.rs
+++ b/ui/src/pve/qemu/overview.rs
@@ -301,10 +301,10 @@ impl yew::Component for QemuOverviewPanelComp {
status_row(
tr!("CPU usage"),
"fa-cpu",
+ // TRANSLATORS: For example "5% of 24 CPUs"
tr!(
- "{0}% of {1} CPU(s)",
+ "{0}% of {n} CPU" | "{0}% of {n} CPUs" % status.cpus.unwrap_or_default(),
format!("{:.2}", cpu * 100.0),
- status.cpus.unwrap_or_default()
),
)
.value(cpu as f32),
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH widget-toolkit 1/1] utils: use ngettext for number of CPUs
2026-01-28 8:56 [pve-devel] [PATCH widget-toolkit 1/1] utils: use ngettext for number of CPUs Maximiliano Sandoval
2026-01-28 8:56 ` [pve-devel] [PATCH proxmox-datacenter-manager 1/1] use ngettext for the " Maximiliano Sandoval
@ 2026-01-28 9:29 ` Maximiliano Sandoval
1 sibling, 0 replies; 3+ messages in thread
From: Maximiliano Sandoval @ 2026-01-28 9:29 UTC (permalink / raw)
To: pve-devel
Maximiliano Sandoval <m.sandoval@proxmox.com> writes:
> Note that it is up to the translator to translate the singular using
> {1}, for example one could translate it as "{0}% of one CPU" in British
> English.
>
> The string will be extracted as:
>
> ```
> #. TRANSLATORS: For example "5% of 24 CPUs"
> #: proxmox-widget-toolkit/src/Utils.js:1123
> #, javascript-format
> msgid "{0}% of {1} CPU"
> msgid_plural "{0}% of {1} CPUs"
> msgstr[0] "{0}% de {1} CPU"
> msgstr[1] "{0}% de {1} CPUs"
> ```
>
> xgettext has some understanding of javascript and mistakenly thinks that
> '%' will reference a variable, hence the javascript-format hint, but
> this is a pre-existing issue.
>
> [1] https://www.gnu.org/software/gettext/manual/html_node/javascript_002dformat.html
>
> Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
> ---
> src/Utils.js | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/Utils.js b/src/Utils.js
> index 5457ffa..ed51ce5 100644
> --- a/src/Utils.js
> +++ b/src/Utils.js
> @@ -1118,7 +1118,8 @@ Ext.define('Proxmox.Utils', {
>
> render_cpu_usage: function (val, max) {
> return Ext.String.format(
> - `${gettext('{0}% of {1}')} ${gettext('CPU(s)')}`,
> + // TRANSLATORS: For example "5% of 24 CPUs"
> + ngettext('{0}% of {1} CPU', '{0}% of {1} CPUs', max),
> (val * 100).toFixed(2),
> max,
> );
Since this is, perhaps, the first use of ngettext in our javascript
codebase I tested:
- Extracted the strings in proxmox-i18n
- translated the string
- See that it is translated both in ts singular and plural forms
Note that one way around to getting the javascript-format (this is the
only string that gets this hint, and wrongly at it) would be to escape
the % sign as %% but Ext.String.format does not understand this escape
and would display it literally. The javascript-format hint seems to be
ultimately harmless in this context.
Note however that when the format hint, gettext understating of the
language, and our use of it align, then it would be actually helpful.
For example, `msgfmt --check` would check that strings with rust-format
are properly formatted. For example:
#: somewhere
#, rust-format
msgid "Hello {0}"
msgstr "Hola {1}"
would throw an error while building proxmox-i18n instead of crashing at
runtime and multiple times errors like this one have been spotted during
review of translations.
We would get this for free for Debian 14 if gettext is bumped to 0.24 or
newer.
--
Maximiliano
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-28 9:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-28 8:56 [pve-devel] [PATCH widget-toolkit 1/1] utils: use ngettext for number of CPUs Maximiliano Sandoval
2026-01-28 8:56 ` [pve-devel] [PATCH proxmox-datacenter-manager 1/1] use ngettext for the " Maximiliano Sandoval
2026-01-28 9:29 ` [pve-devel] [PATCH widget-toolkit 1/1] utils: use ngettext for " Maximiliano Sandoval
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox