When running lupdate none of the qsTr in the qml files are recognized. The resulting .ts file doesn't contain any translation context.
$ lupdate -verbose App.pro
Updating 'translations/en.ts'...
Found 0 source text(s) (0 new and 0 already existing)
The project should be set up correctly:
OTHER_FILES += \
content/main.qml
TRANSLATIONS += \
translations/en.ts
In the main.qml among other things:
menuBar: MenuBar {
Menu {
title: qsTr("File")
MenuItem {
text: qsTr("Open")
onTriggered: Qt.quit();
}
}
Menu {
title: qsTr("...")
MenuItem {
text: qsTr("About")
onTriggered: {
aboutApplicationDialog.open()
}
}
}
}
You can generate the translation file by running
lupdateon QML file :To get the .ts file by running
lupdateon the project .pro file you can use a workaround. From the Qt documentation :If you specify your .qml files in the application like :
When you run
lupdateon the project .pro, the resulting .ts file will contain the QML translation context.Note that you must stick to the brace style shown, using an alternate style such as e.g.
fails (at least on OS X 10.12 / Qt 5.7) with large amounts of compiler warnings and errors that are far from giving any hint at the actual problem, e.g.
Alternately, you can use a continuation character: