translate in qml and C++
-
Hello good day, I have a question about what is happening to me, I am using a QML application that receives the label texts from C++, and I want to translate these texts, I apply my .ts and .qm file and only the QML texts are translated ( I added qsTr("text")), in C++ I have placed tr and QT_TR_NOOP but none sends me the translated, my labels are in their original language. What could I do? Thank you very much for your time and have a nice day!!!
-
Hi,
How are you changing the language of your application.
-
hello, in C++ I do it with tr("text to translate") and in qml I do it with qsTr("text to translate"). The .ts file does detect the text for me, only that when applying the translation the text is in the original language.
Something to add is that I added the text to a component in C++ and then send it to QML to print.
-
That does not answer my original question, when/how are you loading the translator ?
-
Hello, in case it helps someone in the future, I was able to solve it by changing the way of installing the translation, since I have several classes and it was not applied to any of them.
I changed the app.installTranslator(&_translator);
by: QCoreApplication::installTranslator(&_translator);