Kefu Chai <[email protected]> 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="<[email protected]>" \ > --copyright-holder="Copyright (C) Proxmox Server Solutions GmbH > <[email protected]> & 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
