qtqmlqt-linguist

Why lupdate not include qml qstr string into .ts file?


I have this .pro file :

TEMPLATE = subdirs
SUBDIRS += internal app

app.depends = internal
app.subdir = src/app
internal.subdir = src/internal

TRANSLATIONS = \
    $$PWD/translations/croatian.ts \
    $$PWD/translations/danish.ts \
    $$PWD/translations/english.ts \
    $$PWD/translations/french.ts \
    $$PWD/translations/german.ts \
    $$PWD/translations/italian.ts \
    $$PWD/translations/norwegian.ts \
    $$PWD/translations/portuguese.ts \
    $$PWD/translations/romanian.ts \
    $$PWD/translations/spanish.ts

internal.pro is this:

TEMPLATE = lib
TARGET = internal
CONFIG += c++1z

QT += core core-private gui quick serialport sql multimedia

DEFINES += CURRENT_PATH=\\\"$$PWD\\\"

CONFIG(release, debug|release) {
    CONFIG += qtquickcompiler
    QMAKE_CXXFLAGS += -O3
}

CONFIG(debug, debug|release) {
    QMAKE_CXXFLAGS += -O0
    QMAKE_CXXFLAGS -= -O1
    QMAKE_CXXFLAGS -= -O2
    QMAKE_CXXFLAGS -= -O3
    QMAKE_CXXFLAGS += --debug
}

#MS_SKELETON_MODULES = core utils network
#include($$PWD/../external/ms-skeleton/ms-skeleton.pri)

include($$PWD/aggiornamento/aggiornamento.pri)
include($$PWD/allarmi/allarmi.pri)
include($$PWD/comunicazione/comunicazione.pri)
include($$PWD/core/core.pri)
include($$PWD/jsoncpp/jsoncpp.pri)
include($$PWD/mqtt/mqtt.pri)
include($$PWD/other/other.pri)
include($$PWD/parametri/parametri.pri)
include($$PWD/programs/programs.pri)
include($$PWD/serializer/serializer.pri)

unix: target.path = /opt/Tagliavini/lib
!isEmpty(target.path): INSTALLS += target

and app.pro is this :

TEMPLATE = app
TARGET = UserInterface
CONFIG += c++1z

QT += core gui quick sql multimedia

DEFINES += CURRENT_PATH=\\\"$$PWD\\\"

CONFIG(release, debug|release) {
    CONFIG += qtquickcompiler
    QMAKE_CXXFLAGS += -O3
}

CONFIG(debug, debug|release) {
    QMAKE_CXXFLAGS += -O0
    QMAKE_CXXFLAGS -= -O1
    QMAKE_CXXFLAGS -= -O2
    QMAKE_CXXFLAGS -= -O3
    QMAKE_CXXFLAGS += --debug
}

LIBS += -L$$shadowed($$PWD)/../internal/ -linternal

INCLUDEPATH += \
    $$PWD/../internal \
    $$PWD/../external/ms-skeleton

SOURCES += $$PWD/main.cpp

RESOURCES += \
    $$PWD/../../font/fonts.qrc \
    $$PWD/../../images/images.qrc \
    $$PWD/qml/qml.qrc \
    $$PWD/../../sounds/sounds.qrc

unix: target.path = /opt/Tagliavini/bin
!isEmpty(target.path): INSTALLS += target

when i try to create file .ts with lupdate , the files are generated correctly , but the file .ts not cointeins the qstr strings that are into qml files. ( the file qml are into app.pro ), instead the string that i want to translate into .cpp files are all recognized correctly and put into .ts file.(these are into internal.pro) Where is the problem??


Solution

  • It seems that you are including your .qml files in .qrc resources but not in the project SOURCES itself. lupdate will not pick/parse your .qrc files to list .qml files. So, you will have to add your .qml files to SOURCES either one-by-one or per directory.

    lupdate_only{
    SOURCES+=example.qml
    SOURCES+=app/FancyControls/*.qml
    }
    

    This will duplicate your QML file entries in Qt Creator project pane tree which is not very desirable. So, you can comment out those lines in your .pro file and uncomment it before any lupdate. It's also mandatory to fence those imports in lupdate_only{} conditional statement. Make sure that there is no space between lupdate_only and the curly bracket. Actually, your C/C++ compiler would not expect a qml file to be compiled.