react-gettext-parser uses this library to compile POT files from JSX and JS sources.
However, if you have a function call to ngettext or other plural translations, it will result in only one empty string in the msgstr array of the translation. gettext-parser will rely on the number of msgstr elements to decide whether it should render msgstr or msgstr[0] instead of relying on the presence of a msgid_plural key. The relevant code is here: https://github.com/andris9/gettext-parser/blob/master/lib/pocompiler.js#L104
For me this results in having a POT file like this:
This could be fixed in react-gettext-parser but I think it might be more correct for gettext-parser to produce msgstr[0] if a msgid_plural is present and has content.
react-gettext-parser
uses this library to compile POT files from JSX and JS sources. However, if you have a function call tongettext
or other plural translations, it will result in only one empty string in themsgstr
array of the translation.gettext-parser
will rely on the number ofmsgstr
elements to decide whether it should rendermsgstr
ormsgstr[0]
instead of relying on the presence of amsgid_plural
key. The relevant code is here: https://github.com/andris9/gettext-parser/blob/master/lib/pocompiler.js#L104For me this results in having a POT file like this:
instead of
which leads to my gettext tool throwing an error.
This could be fixed in
react-gettext-parser
but I think it might be more correct forgettext-parser
to producemsgstr[0]
if amsgid_plural
is present and has content.See also https://github.com/laget-se/react-gettext-parser/issues/6.