muzika icon indicating copy to clipboard operation
muzika copied to clipboard

Wrong ngettext usage

Open yakushabb opened this issue 1 year ago • 3 comments

Hi, I believe the following ngettext usage are wrong because there are missing strings after building the pot file.

    const success_toast = () => {
      add_toast(
        ngettext(
          vprintf(_("%d song removed from playlist"), [items.length]),
          vprintf(_("%d songs removed from playlist"), [items.length]),
          items.length,
        ),
      );
    };

            add_toast(
              params.has("next")
                ? ngettext(
                  // Translators: %s is a song's name
                  vprintf(_("Playing “%s” next"), [normalized_title]),
                  vprintf(_("Playing %d songs next"), [tracks.length]),
                  tracks.length,
                )
                : ngettext(
                  // Translators: %s is a song's name
                  vprintf(_("Added “%s” to queue"), [normalized_title]),
                  vprintf(_("Added %d songs to queue"), [tracks.length]),
                  tracks.length,
                ),
            );

yakushabb avatar Mar 31 '24 18:03 yakushabb

Hmm. I can find the strings in the pot file though??

vixalien avatar May 17 '24 02:05 vixalien

They aren't in ngettext format.

#: src/pages/playlist.ts:254
#, c-format
msgid "%d song removed from playlist"
msgstr ""

#: src/pages/playlist.ts:255
#, c-format
msgid "%d songs removed from playlist"
msgstr ""

#. Translators: %s is a song's name
#: src/player/queue.ts:392 src/player/queue.ts:447
#, c-format
msgid "Playing “%s” next"
msgstr ""

#: src/player/queue.ts:448
#, c-format
msgid "Playing %d songs next"
msgstr ""

#: src/player/queue.ts:454
#, c-format
msgid "Added %d songs to queue"
msgstr ""

The code should be something like that

return Gettext.ngettext("%d day ago", "%d days ago", days).format(days);

And pot file should be something like that

#: src/utils.ts:55
#, c-format
msgid "%d day ago"
msgid_plural "%d days ago"
msgstr[0] ""
msgstr[1] ""

yakushabb avatar May 17 '24 07:05 yakushabb

Oh you're correct. Thanks, I will try to fix that soon™

vixalien avatar May 18 '24 11:05 vixalien