Planned maintenance has been done but it did not solve the problem. So work will continue on this and a new time for trying updates will be announced asap.

Cannot Translate ListElement "name" Variables



  • Hello all,
    I am trying to translate my qt application for first time. Everything does OK, but only ListElement's wont translate. Part of code that I am trying to translate:

    id: leftMenu
                model:tmodel
            }
            ListModel{
                id: tmodel
                ListElement{
                    name: QT_TR_NOOP("Left Window")
                    st:"LeftWindow"
    
                }
                ListElement{
                    name: QT_TR_NOOP("Right Window")
                    st:"RightWindow"
                }
            }
            Text {
                text: qsTr(tmodel.get(0).name);
                }
    

    When I run lupdate, it shows only ones with the QT_TR_NOOP("").
    If I edit qsTr code as,

    Text {
                text: qsTr("hello");
                }
    

    It returns a qsTr on QT Linguist. I guess, it means, "tmodel.get(0).name" does not return a string value.
    What can I do guys?



  • @closx in you ListElement items, replace QT_TR_NOOP() with qsTr() and remote qsTr() from the text item.

    Something like this

    ListModel{
        id: tmodel
        ListElement{
            name: qsTr("Left Window")
            st:"LeftWindow"
    
        }
        ListElement{
            name: qsTr("Right Window")
            st:"RightWindow"
        }
    }
    
    Repeater {
        model:tmodel
        Text {
            text: name
        }    
    }
    

    Perhaps you need to update your translation file.



  • @KroMignon LOVE YOU!
    Thank you very much, worked w/out problems, and made me understand my mistake.
    note: Needed to update .ts file and release .qm file after changing code.