Unsolved How can I add language translation for dynamic text
-
I am working on QT-5.6.3 based embedded qt application.
The application supports multiple languages, default is English.
In the application, I have added fixed text string translation for other languages.
How can I add dynamic text string translations? -
@Rathore hi, can you be a bit more specific in your situation ?
what exactly do you want to do ?
You know about QObject::tr() and QTranslator?
-
@Rathore said in How can I add language translation for dynamic text:
How can I add dynamic text string translations?
Have you checked the documentation about Writing Source Code for Translation?
-
@J-Hilk I have qml based application. I have array of Qstrings defined in .h file. I have used QObject::tr() is used to recognized these strings by lupdate and Qt Linguist. I have added the translation for these strings.
When the language selected is other than english, these strings should be translated and displayed in selected language, as I have added the translations in Qt Linguist. But these strings are displayed in english only. -
@Rathore
ok, so far so good,you should I assume you have read the documentation @Pablo-J-Rogina linked?
So how do you access the strings in QML ?
IIRC than Qt 5.6.3 does not yet have the automatic QML binding reevaluation when a language changes. And you'll have to do some trickery here
See this blog post as an example on how its done before 5.10 and after
https://embeddeduse.com/2017/11/12/new-in-qt-5-10-dynamic-language-change-in-qml/if you assign a string instead of a binding, you can/have to recall the function, where the assignment happens, after the translation