Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to run lupdate with a QMAKE CONFIG?



  • I posted the same question on stackoverflow after a few days:

    https://stackoverflow.com/questions/58029996/how-to-run-qts-lupdate-tool-with-a-qmake-config

    .

    .

    .

    .

    I use such a construct in my project files:

    LANGUAGES = de
    TRANSLATION_NAME = authorization
    include(../../gen_translations.pri)
    

    where gen_translations.pri looks like so:

    # parameters: var, prepend, append
    defineReplace(prependAll) {
     for(a,$$1):result += $$2$${a}$$3
     return($$result)
    }
    
    TRANSLATIONS = $$prependAll(LANGUAGES, $$PWD/libs/$$TRANSLATION_NAME/translations/lib$${TRANSLATION_NAME}_, .ts)
    
    TRANSLATIONS_FILES =
    
    qtPrepareTool(LRELEASE, lrelease)
    
    for(tsfile, TRANSLATIONS) {
     qmfile = $$shadowed($$tsfile)
     qmfile ~= s,.ts$,.qm,
     qmdir = $$dirname(qmfile)
     !exists($$qmdir) {
     mkpath($$qmdir)|error("Aborting.")
     }
     command = $$LRELEASE -removeidentical $$tsfile -qm $$qmfile
     system($$command)|error("Failed to run: $$command")
     TRANSLATIONS_FILES += $$qmfile
    }
    
    for(qmentry, $$list($$TRANSLATIONS_FILES)) {
      qmpath = $$OUT_PWD/../translations
      qmpathname = $$replace(qmpath,/,)
      qmpathname = $$replace(qmpathname,\.,)
      qmpathname = $$replace(qmpathname,:,)
      qmpathname = $$replace(qmpathname," ",)
      qmentity = qmfiles_$${qmpathname}
      eval($${qmentity}.files += $$qmentry)
      eval($${qmentity}.path = $$qmpath)
      INSTALLS *= $${qmentity}
    }
    

    It generates the *.qm files for me and moves them to a defined location with make install.

    I do not want qmake to execute that whole stuff for each build on my developing machine. Therefore I want to make the stuff conditional by wrapping it for qmake:

    translate{
    LANGUAGES = de
    TRANSLATION_NAME = authorization
    include(../../gen_translations.pri)
    }
    

    That way I can decide when I want to get *.qm files and when not.
    But then I am unable to run lupdate on the project file because it is blocked by that conditional.

    I am sure, that someone has a better idea to accomplish the task.

    Thanks in advance.


Log in to reply