Important: Please read the Qt Code of Conduct -

How to run lupdate with a QMAKE CONFIG?

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





    I use such a construct in my project files:

    LANGUAGES = de
    TRANSLATION_NAME = authorization

    where gen_translations.pri looks like so:

    # parameters: var, prepend, append
    defineReplace(prependAll) {
     for(a,$$1):result += $$2$${a}$$3
    TRANSLATIONS = $$prependAll(LANGUAGES, $$PWD/libs/$$TRANSLATION_NAME/translations/lib$${TRANSLATION_NAME}_, .ts)
    qtPrepareTool(LRELEASE, lrelease)
    for(tsfile, TRANSLATIONS) {
     qmfile = $$shadowed($$tsfile)
     qmfile ~= s,.ts$,.qm,
     qmdir = $$dirname(qmfile)
     !exists($$qmdir) {
     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:

    LANGUAGES = de
    TRANSLATION_NAME = authorization

    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