vixalien / muzika

Elegant music streaming app
GNU General Public License v3.0
268 stars 17 forks source link

Wrong ngettext usage #125

Open yakushabb opened 6 months ago

yakushabb commented 6 months ago

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,
                ),
            );
vixalien commented 4 months ago

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

yakushabb commented 4 months ago

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] ""
vixalien commented 4 months ago

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