Qt linguist lupdate ignores qml files

When launched, lupdatenone of qsTrthe qml files are recognized. The resulting .ts file does not contain a broadcast context.

$ lupdate -verbose App.pro
Updating 'translations/en.ts'...
    Found 0 source text(s) (0 new and 0 already existing)

The project must be configured correctly:

OTHER_FILES += \
    content/main.qml

TRANSLATIONS += \
    translations/en.ts

In main.qml, by the way:

menuBar: MenuBar {
    Menu {
        title: qsTr("File")
        MenuItem {
            text: qsTr("Open")
            onTriggered: Qt.quit();
        }
    }
    Menu {
        title: qsTr("...")
        MenuItem {
            text: qsTr("About")
            onTriggered: {
                aboutApplicationDialog.open()
            }
        }
    }
}
+4
source share
3 answers

You can generate the translation file by executing lupdatein the QML file:

lupdate main.qml -ts main.ts

To get the .ts file by running lupdatethe .pro project file, you can use a workaround. From the Qt documentation:

lupdate . lupdate .pro . . , SOURCES HEADERS .pro . , .

SOURCES ++. QML JavaScript , ++. lupdate_only {...} , lupdate .qml, ++ .

.qml , :

lupdate_only{
SOURCES = content/main.qml
}

lupdate .pro, .ts QML.

, , , ,

# DON'T USE, FAILS!
lupdate_only
{
SOURCES = content/main.qml
}

( , OS X 10.12/Qt 5.7) , , - , .

clang: warning: <qml source file>: 'linker' input unused
clang: warning: argument unused during compilation: '-g'
clang: warning: argument unused during compilation: '-isysroot /Applications/Xcode_7.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk'
  ... 
clang: error: no such file or directory: 'Page1.o'
clang: error: no such file or directory: 'Page1Form.ui.o'

:

lupdate_only \
{
SOURCES = content/main.qml
}
+7

Qt 5.8.0 .pro.

QML .qrc, :

  • lupdate

.pro :

RESOURCES += application.qrc

.qrc - XML , qtcreator . qrc : http://doc.qt.io/qt-5/qtquick-deployment.html#managing-resource-files-with-the-qt-resource-system

.qrc ​​ lupdate 2016-10-25: http://code.qt.io/cgit/qt/qttools.git/commit/?id=f2ebd51d96ad49eb826a4e37e67d506fffcbd40c Qt 5.7.1, 5.7.2 ( - ).

+2

lupdate_only . , QtCreator qml , qml .

, , script:

#!/bin/bash
../../5.5/gcc_64/bin/lupdate *.pro
for tr in *.ts
do
  ../../5.5/gvv_64/bin/lupdate *.qml -ts $ts
done
0

Source: https://habr.com/ru/post/1542769/


All Articles