From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id E198B1FF137 for ; Tue, 17 Feb 2026 16:45:44 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 05F2883E9; Tue, 17 Feb 2026 16:46:35 +0100 (CET) From: Maximiliano Sandoval To: Kefu Chai Subject: Re: [PATCH proxmox-i18n v2] add pgettext() and npgettext() support for context-aware translations In-Reply-To: <20260206054707.1465261-2-k.chai@proxmox.com> (Kefu Chai's message of "Fri, 6 Feb 2026 13:47:08 +0800") References: <20260205101613.1067594-2-k.chai@proxmox.com> <20260206054707.1465261-2-k.chai@proxmox.com> User-Agent: mu4e 1.12.9; emacs 30.1 Date: Tue, 17 Feb 2026 16:45:59 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1771343153196 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.086 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: RXUHWJXQIH7USKQ3BRCWXEOQ6KJWLN6X X-Message-ID-Hash: RXUHWJXQIH7USKQ3BRCWXEOQ6KJWLN6X X-MailFrom: m.sandoval@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: pve-devel@lists.proxmox.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Kefu Chai writes: Thanks for the update. Comments below. > This commit adds message context (msgctxt) support to the JavaScript > [..] > Makefile | 1 + > po2js.pl | 69 ++++++++++++++++++++++++++++++++++++++++++++++++-------- > 2 files changed, 61 insertions(+), 9 deletions(-) > > diff --git a/Makefile b/Makefile > index 86bd723..3feaee7 100644 > --- a/Makefile > +++ b/Makefile > @@ -155,6 +155,7 @@ define potupdate > --package-version="$(shell cd $(2);git rev-parse HEAD)" \ > --msgid-bugs-address="" \ > --copyright-holder="Copyright (C) Proxmox Server Solutions GmbH & the translation contributors." \ > + --keyword=npgettext:1c,2,3 \ You were right in your previous reply, however as I mentioned, gettext by default has keys for gettext, ngettext, pgettext and npgettext. There is no need to add this here. > --output="$(1)".pot > endef > > diff --git a/po2js.pl b/po2js.pl > index 316c0bd..4b7b044 100755 > [..] > > if ($outfile) { I tested this with pve-manager. - Sprinkled a few uses of pgettext - Extracted the strings with make do_update at proxmox-i18n - Translated two strings with context - Checked that the translated string were visible at the web UI and that each one had the correct translation given its context To make the above work I had to patch proxmox-biome to accept the ngettext and pngettext keywords: modified src/biome.json @@ -128,7 +128,9 @@ "Proxmox", "eslint", "ngettext", - "gettext" + "gettext", + "pgettext", + "npgettext" ] } } Otherwise `make deb` would fail when building the .debs. I also had to modify the index.html.tpl to pve-manager to have default implementations for these fns, otherwise the UI won't work if there is no language selected (which is the default): modified www/index.html.tpl @@ -27,6 +27,8 @@ [% END %] [%- IF debug %] There are similar files at pmg-gui and proxmox-backup-server that would also need updating. -- Maximiliano