[pve-devel] [PATCH proxmox-i18n 2/2] po2js: add ngettext support
Maximiliano Sandoval
m.sandoval at proxmox.com
Thu Jul 31 13:37:40 CEST 2025
Maximiliano Sandoval <m.sandoval at 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
More information about the pve-devel
mailing list