Thanks for the pointers. Interesting to see that they have implemented a
plural choice formula evaluation engine as well, just with a more restricted
set of formulas.
> Another thing is that if the
> number is negative, then the call is not considered plural at all
However, this is a thing xgettext cannot recognize, because the third argument
to tr() may be variable or computed.
> Furthermore, as above, the context, even if empty, must be supplied due to
> argument ordering (cf. my recent message on empty contexts).
Yes, gettext supports empty contexts. xgettext distinguishes an empty
context from a null context, like tr does: QObject::tr has the prototype
static QString tr(const char *sourceText, const char *context = NULL, int n = -1);
so a context = "" is different from a context = NULL.
> So, the question is: should/could this (or a part of it) be supported by
> xgettext?
It will be supported in gettext 0.18:
$ cat foo.cc
QString msg = tr("%n bird(s)", "", 10); // plural call
QString msg = tr("%1 bird(s)", "").arg(10); // ordinary call
QString msg = tr("%1 eagle(s)").arg(10); // ordinary call
$ xgettext --omit-header --no-location \
--qt --keyword=tr:1,1t --keyword=tr:1,2c,2t --keyword=tr:1,1,2c,3t \
-o - foo.cc
#, qt-plural-format
msgctxt ""
msgid "%n bird(s)"
msgid_plural "%n bird(s)"
msgstr[0] ""
msgstr[1] ""
#, qt-format
msgctxt ""
msgid "%1 bird(s)"
msgstr ""
#, qt-format
msgid "%1 eagle(s)"
msgstr ""
Note:
- the use of qt-plural-format to denote a string with %n,
- msgid and msgid_plural are the same in this case,
- the msgctxt has been extracted.
Bruno