From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: Kefu Chai <k.chai@proxmox.com>
Cc: pve-devel@lists.proxmox.com
Subject: Re: [PATCH proxmox-i18n v2] add pgettext() and npgettext() support for context-aware translations
Date: Tue, 17 Feb 2026 16:45:59 +0100 [thread overview]
Message-ID: <s8ov7fvmkzs.fsf@proxmox.com> (raw)
In-Reply-To: <20260206054707.1465261-2-k.chai@proxmox.com> (Kefu Chai's message of "Fri, 6 Feb 2026 13:47:08 +0800")
Kefu Chai <k.chai@proxmox.com> 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="<support@proxmox.com>" \
> --copyright-holder="Copyright (C) Proxmox Server Solutions GmbH <support@proxmox.com> & 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 @@
<script type='text/javascript'>
function gettext(message) { return message; }
function ngettext(singular, plural, count) { return count === 1 ? singular : plural; }
+ function pgettext(context, message) { return message; }
+ function pngettext(context, singular, plural, count) { return count === 1 ? singular : plural; }
</script>
[% END %]
[%- IF debug %]
There are similar files at pmg-gui and proxmox-backup-server that would
also need updating.
--
Maximiliano
prev parent reply other threads:[~2026-02-17 15:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-05 10:16 [PATCH proxmox-i18n v1] " Kefu Chai
2026-02-05 13:15 ` Maximiliano Sandoval
2026-02-06 5:44 ` Kefu Chai
2026-02-06 5:47 ` [PATCH proxmox-i18n v2] " Kefu Chai
2026-02-17 15:45 ` Maximiliano Sandoval [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s8ov7fvmkzs.fsf@proxmox.com \
--to=m.sandoval@proxmox.com \
--cc=k.chai@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.