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]));
}
const char* myStrings[] = { "String 1", "String 2", "String 3" };
for (int aaa = 0; aaa < 3; aaa++)
{
myLabel[aaa]->setText(tr(myStrings[aaa]));
}
To copy to clipboard, switch view to plain text mode
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"));
myLabel[0]->setText(tr("String 1"));
myLabel[1]->setText(tr("String 2"));
myLabel[2]->setText(tr("String 3"));
To copy to clipboard, switch view to plain text mode
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.
Bookmarks