Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Translations in QML files
QtWS25 Last Chance

Translations in QML files

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 3.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    durfejs
    wrote on 14 Nov 2011, 13:27 last edited by
    #1

    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

    We can get richer only with progress

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vishu
      wrote on 7 Aug 2013, 05:13 last edited by
      #2

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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved