From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: Re: [pve-devel] [PATCH proxmox-i18n 2/2] po2js: add ngettext support
Date: Thu, 31 Jul 2025 13:37:40 +0200 [thread overview]
Message-ID: <s8ojz3oh9q3.fsf@proxmox.com> (raw)
In-Reply-To: <20250731112822.297009-2-m.sandoval@proxmox.com> (Maximiliano Sandoval's message of "Thu, 31 Jul 2025 13:26:00 +0200")
Maximiliano Sandoval <m.sandoval@proxmox.com> writes:
> @@ -112,6 +136,20 @@ function gettext(buf) {
> }
> return data[0] || buf;
> }
> +
> +function ngettext(singular, plural, n) {
> + const msg_idx = Number($plural_forms);
> + const digest = fnv31a(singular);
> + const translation = __proxmox_i18n_plurals_msgcat__[digest];
> + if (!translation[msg_idx]) {
This should be:
if (!translation || msg_idx >= translation.length) {
or similar. It is possible a message might be missing translations for
certain plural forms.
> + if (n === 1) {
> + return singular;
> + } else {
> + return plural;
> + }
> + }
> + return translation[msg_idx];
> +}
> __EOD
>
> if ($outfile) {
--
Maximiliano
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-07-31 11:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-31 11:25 [pve-devel] [PATCH proxmox-i18n 1/2] format with proxmox-perltidy Maximiliano Sandoval
2025-07-31 11:26 ` [pve-devel] [PATCH proxmox-i18n 2/2] po2js: add ngettext support Maximiliano Sandoval
2025-07-31 11:37 ` Maximiliano Sandoval [this message]
2025-07-31 12:01 ` [pve-devel] applied: [PATCH proxmox-i18n 1/2] format with proxmox-perltidy Thomas Lamprecht
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=s8ojz3oh9q3.fsf@proxmox.com \
--to=m.sandoval@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox