Empty .ts file after lupdate



  • So, I've ran into a problem. When I use lupdate on Qt Creator ( Tools -> External -> Linguist -> Update Translations (lupdate) ) or by terminal ( lupdate - recursive /localization/proj.pro) the .ts file is created but there is no data inside.

    what can be the reason that blank file is created without any data?


  • Moderators

    You have marked your strings with "tr", right? Then it is indeed strange that you are getting no output.



  • I marked every string by qsTr(becouse it's qml) and qt_tr_noop() -> elements of the lists.


  • Moderators

    Maybe you have hit the old qmake/ lupdate bug: it does not send QML files to lupdate.

    Add this in your .pro file:
    @
    hack_for_lupdate { # or any other text - it does not matter.
    SOURCES += your/qml/files.qml
    }
    @



  • What should be the effect of this code?


  • Moderators

    Whwn building the project, qmake will completely ignore it. lupdate, however will now treat your QML files as real source files: and so it will parse them in search for translatable strings.

    I think this bug was fixed in Qt5, probably also in recent Qt 4 versions (4.8.x).



  • It's problem becouse I use QT5. Qt Creator 2.5.0 Based on Qt 4.8.2 (64 bit).
    Another problem is that I can't build this project on my computer(compiler problem with listing but will be solved in couple days).
    My project file:

    TEMPLATE = lib

    include(../smarteyeradar.pri)

    unix:DEFINES += _LINUX
    _x86
    BOOST_THREAD_USE_LIB

    win32:QMAKE_CXXFLAGS = -Zc:wchar_t

    QT += opengl gui core declarative sql network

    DEFINES += GUI_REVISION=\"$(REVISION)\"

    TARGET = gui-$(REVISION)

    unix:QMAKE_POST_LINK += ln -s -f $(TARGET) $$DESTDIR/libgui.a

    CONFIG += static

    HEADERS +=
    headers_files.h

    SOURCES +=
    files.cpp

    RESOURCES += resources.qrc

    hack_for_lupdate{
    OTHER_FILES +=
    \qml\qml_files.qml
    }
    TRANSLATIONS = gui3.ts

    Is it right? Becouse it doesn't work.


  • Moderators

    If you only have one QML file and it's path is "\qml\qml_files.qml", then yes - you just need to change that into SOURCES and not OTHER_FILES. Also, Qt expects you to use Unix paths (forward slashes "/"). Lastly, QtQuick1 (devlarative) module is deprecated in Qt5.2. You might consider porting to QtQuick2.

    However, I don't see QMLFILES variable anywhere in this listing. I guess you need to create a small example application and see if it works there, then go over your config slowly and see what is wrong.



  • Project is much bigger but I don't want you to scroll all of this files thats why I call him "qml_filles.qml". All of files I put between {}.

    Now it looks:
    TEMPLATE = lib

    include(../smarteyeradar.pri)

    unix:DEFINES += _LINUX \ _x86 \ BOOST_THREAD_USE_LIB

    win32:QMAKE_CXXFLAGS = -Zc:wchar_t

    QT += opengl gui core declarative sql network

    DEFINES += GUI_REVISION=\\”$(REVISION)\\”

    TARGET = gui-$(REVISION)

    unix:QMAKE_POST_LINK += ln -s -f $(TARGET) $$DESTDIR/libgui.a

    CONFIG += static

    HEADERS += headers_files.h

    SOURCES += files.cpp

    RESOURCES += resources.qrc

    hack_for_lupdate{
    OTHER_FILES +=
    /qml/qml_files.qml
    }
    TRANSLATIONS = gui3.ts

    It is still not working.



  • I installed the newest version of Qt and it isn't help me...



  • I got some progress but... When I use lupdate (even with -recursive) gui.pro the .ts file is empty. I tried to create the .ts file with one qml file and it's ok, the file is created.
    What's wrong when I want to make the ts from all project file where are qml files...

    The problem is that I haven't got in my file.pro SOURCES qml files with strings. QT locates those files in "OTHER FILES" and lupdate doesn't see them. I tried put them into SOURCES and it's ok but project doesn't compiling.

    Solutions:

    1. How can I tell lupdate to translate "OTHER FILES"??
    2. Solving the problem with compiling

    PS: -recursive does not help...

    PLZ help



  • Lupdate doesn't care about conditionals, so you can do something like this in your.pro file:
    evilhack{
    SOURCES +=
    qml\qmlfile1.qml
    qml\qmlfile2.qml
    qml\qmlfile3.qml
    }
    and it will be picked up by lupdate, but left out from compilations etc


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.