Friday, December 9, 2011

QT Linguist does not show plurals : solution

I have been using QT Linguist for a large software project. I have had a need to include translatable texts that are not yet used in the code itself.

For including texts for translation, QT Linguist manual suggests to use QT_TR_NOOP or QT_TRANSLATE_NOOP.

For some reason, I was unable to see plurals when editing texts in QT linguist. It took me few hours, but I found out that when using QT_TR_NOOP or QT_TRANSLATE_NOOP macros, the plurals will not be generated when running "lupdate" command.

So, instead of using:
QT_TR_NOOP("You got %n hellos");
you need to use to
tr("You got %n hellos");
get the singular and plural inputs to be shown in QT Linguist.

That pretty much destroys the idea for the macros... This might be version and/or language specific issue, but if you encounter this problem, try to change the macros to actual tr()-calls.