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 82AED1FF165 for ; Thu, 31 Jul 2025 13:36:49 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2C1333953D; Thu, 31 Jul 2025 13:38:14 +0200 (CEST) From: Maximiliano Sandoval To: pve-devel@lists.proxmox.com In-Reply-To: <20250731112822.297009-2-m.sandoval@proxmox.com> (Maximiliano Sandoval's message of "Thu, 31 Jul 2025 13:26:00 +0200") References: <20250731112822.297009-1-m.sandoval@proxmox.com> <20250731112822.297009-2-m.sandoval@proxmox.com> User-Agent: mu4e 1.12.9; emacs 30.1 Date: Thu, 31 Jul 2025 13:37:40 +0200 Message-ID: MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1753961848852 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.095 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH proxmox-i18n 2/2] po2js: add ngettext support 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: > @@ -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