From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id D5DEF1FF13B for ; Wed, 28 Jan 2026 10:29:30 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5A4D0D3DC; Wed, 28 Jan 2026 10:29:53 +0100 (CET) From: Maximiliano Sandoval To: pve-devel@lists.proxmox.com In-Reply-To: <20260128085614.91769-1-m.sandoval@proxmox.com> (Maximiliano Sandoval's message of "Wed, 28 Jan 2026 09:56:11 +0100") References: <20260128085614.91769-1-m.sandoval@proxmox.com> User-Agent: mu4e 1.12.9; emacs 30.1 Date: Wed, 28 Jan 2026 10:29:47 +0100 Message-ID: MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1769592522124 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.089 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_SHORT 0.001 Use of a URL Shortener for very short URL SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [gnu.org] Subject: Re: [pve-devel] [PATCH widget-toolkit 1/1] utils: use ngettext for number of CPUs X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Maximiliano Sandoval 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 > --- > 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