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"
- }
- }
- }
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:
- app->installTranslator(translator);
Like this:

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
0 replies
You must log in to post a reply. Not a member yet? Register here!
