So, I found a solution using QT_TRANSLATE_NOOP :
In the following XML, I am doing something like this:
<root> <tag>QT_TRANSLATE_NOOP("context","value")</tag> </root>
And when I want to get the value, I do something like this in cpp:
Q_INVOKABLE QString getTranslation(QString value){ return QApplication::translate("context", value); }
So, to summarize in a few words. I put the QT_TRANSLATE_NOOP macro in my XML file containing the context string (you can select whatever you want) and the value I want it to be translated. Therefore, when I do lupdate myxml.xml -ts myTs.ts, it generates a ts file that has value as the source text in the context specified in the macro. After that, in cpp, I have to create a function that dynamically transfers the translation from the context.
Ispas claudiu
source share