Important: Please read the Qt Code of Conduct -

Couldn't loading the Translation properly at runtime..!

  • 1st.png

    It is the first image showing selection option for the change language, when i clicked upon german language ,

    only some words are changing as you can see , but when i went to the next dialog of the project translation is working fine , coming back to the previous page now ,
    you can see the translation is working properly now,


    Translation.cpp //is like this i'm integrating the C++, as i'm using the //QCoreApplication
    Translation::Translation(QQmlApplicationEngine *engines)
    translator = new QTranslator;
    engine = engines;

    void Translation::languageSelect(QString language)
    if(language == "German")
    else if(language == "English")

    Qt Creator version : 5.10
    Platform : mac os

  • I've had issues with translation before as well. Somehow, retranslate does not notify QML properly of the text changes, hence QML does not repaint all the strings correctly. There is a bug on QT that was fixed in 5.12:

    However, there is a workaround for this. You can create a Q_PROPERTY with an empty string and define all your strings in terms of that empty string.

    readonly property string stringOne: qsTr("stringOne") + emptyStr

    Where emptyStr is a Q_PROPERTY with an empty string.

    Every time you run the reTranslate function, update this empty string with a new empty string. This will force QML to repaint all the strings and your translation will work fine.

  • hi @rrlopez Thank you for the information i tried this bug on both lower and 5.12 versions of Qt Creator , it was working fine in 5.12 version .

  • @rrlopez I tried with QTBUG according to this BUG working correctly in Qt 5.12 , but with number of screens and components i'm using to create ListView, i want to use different list items every time for each and every screens, as i'm facing same issue for translation as i'm posted above.

    Two Components are like this

    Component1.qml //here i’m adding list items

    var settingsMenu = [qsTr("Settings") , qsTr("Change Language") , qsTr(“Options”) , qsTr("Quit")]

    for(var i=0;i<settingsMenu.length;i++){


    //function call for appending the ListModel Elements
    function addmenu(user){

    width: parent.width
    text: menu
    model: settingsModel

    Qt Version: 5.12
    Platform : Windows

    Help me to reach out from this runtime error...
    Thanks In advance.

  • Hi @Kiranachari-Shilpi, what I think its going on is that when you are appending the settingsMenu items to settingsModel, you are not directly creating a binding between the model and the data, hence any change on the language will not affect the settingsModel items. Javascript is not that good when you want to keep bindings on your QML, either properties or any other kind of change (like language changes in this case). I believe you would have to re-run your Component.onCompleted logic to make it re-translate and re-add the items to the settingsModel.
    Other way around that will not need this, is to append on the settingsMenu only the bare strings...
    i.e. var settingsMenu = ["Settings" , "Change Language" , “Options” , "Quit"]
    And on your QML file use qsTr(modelItem).

  • Hi @rrlopez ,
    Sorry for the late response , Thank you so much for the reply,
    It was a very new concept i learned , thank you for your suggestions , my translation project is working perfectly now.

Log in to reply