PDA

View Full Version : lupdate not loading all strings



Momergil
31st July 2014, 21:44
Hello!

I recently started working with translations and I noticed that some of my strings weren't compiled to the .ts files by lupdate, notably those which were generated inside a for() loop translating the strings from an array:



const char* myStrings[] = { "String 1", "String 2", "String 3" };

for (int aaa = 0; aaa < 3; aaa++)
{
myLabel[aaa]->setText(tr(myStrings[aaa]));
}


I did some research in the Qt Linguist Manual and I noticed that it repeatedly talks about "human readable strings" or "user-visible text". Does this means that strings set to translation as in the code above would never work? And I need to write them separatedly? :



myLabel[0]->setText(tr("String 1"));
myLabel[1]->setText(tr("String 2"));
myLabel[2]->setText(tr("String 3"));



Thanks,

Momergil

Added after 1 47 minutes:

I found the answer I seek: use QT_TRANSLATE_NOOP or QT_TR_NOOP arround the strings of the array.

Momergil
31st July 2014, 22:39
For further readers, I just found this old post (http://doc.qt.digia.com/qq/qq03-swedish-chef.html) (it's about Qt3 \o/) that give some tips about translating with Qt, including commentaries about not using the two macros I just presented as solution to my problem :p. I'll still testing the shown alternatives, but they seem reasonable.

wysota
31st July 2014, 23:32
The paper doesn't say anywhere you shouldn't use QT_TR_NOOP. It says you should use it together with tr().