View Full Version : translations in component loaded from QML

16th November 2011, 14:26
Hi there,

I have tied the basic project in Qt Quick. Wizzard creates two qml files: main.qml and MainPage.qml. MainPage.qml is loaded as component in main.qml like this:

initialPage: MainPage {tools: toolBarLayout}

now in MainPage.qml the text says obligatory :

text: qsTr('Hello world!')

but this is not translating properly. I am sure that I have:
1. created properly ts translation file from both main.qml and MainPage.qml (using lupdate)
2. released qm file with linguist
3. loaded qm file into the translator and installed the translator in the main.cpp file

When I move the MainPage.qml snippet directly into main.qml code like this:

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

the "Hello world!" is translated correctly. It seem only in loaded QML components the qsTr function does not look up properly in translator.

Any quesses? Thanks.