Translations in QML files



  • Hi there,

    I have problems with translations (using function qsTr()) in my QML file which is loadad as component into anther QML file.
    I created standard "Hello world!" project in QtQuick. The MainPage.qml file created by Qt Creator is being loaded into main.qml file as a component for initialPage. Here are the codes:

    main.qml:
    @import QtQuick 1.1
    import com.nokia.symbian 1.1

    PageStackWindow {
    id: window
    initialPage: MainPage {tools: toolBarLayout}
    showStatusBar: true
    showToolBar: true

    ToolBarLayout {
        id: toolBarLayout
        ToolButton {
            flat: true
            text: qsTr("Back")
            iconSource: "toolbar-back"
            onClicked: window.pageStack.depth <= 1 ? Qt.quit() : window.pageStack.pop()
        }
    }
    

    }@

    MainPage.qml:

    @import QtQuick 1.1
    import com.nokia.symbian 1.1

    Page {
    id: mainPage
    Text {
    anchors.centerIn: parent
    text: qsTr('Hello world!')
    color: platformStyle.colorNormalLight
    font.pixelSize: 20
    }
    }@

    Problem is that "Back" in main.qml is translated correctly (after all necessary steps with lupdate and linquist resp. lrelease) but "Hello world!" from MainPage.qml does not translate at all.

    NB of course I performed manual loading of QTranslator and istallation in main.cpp file like this:
    @ QTranslator* translator = new QTranslator;

    qDebug()<<"Translating: "<<translator->load(QString("qml/International/inter_sk"));
    
    app->installTranslator(translator);@
    

    Like this:
    !http://wpdevelop.titoyo.eu/devhelp/screen.jpg(QML translation problem)!

    So I think when loading component from QML file then the translation is not working.

    Any guesses why? experiences????
    Thanks a lot

    UPDATE:
    Translation files need to be prepared case sensitively:

    lupdate mainpage.qml -ts inter_sk.ts is wrong
    lupdate MainPage.qml -ts inter_sk.ts is correct



  • Hi,, I stuck in same problem did you solve it,?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.