Unsolved QMake LRELEASE .ts to .qm files
-
Hi,
I'm new in software development and I'm searching for a way to automate the compiling of .ts translation files to .qm files using lrelease.exe in a .pro file. Therefore i need to get the filename out of the .ts filepath and create new .qm files, that $$LRELEASE can compile it and put the .qm files in my DEPLOYMENT_DIR. The following workaround worked for me:# this function is for making a full Path that worked for me on windows: defineReplace(fixPath) { rawPath = $$quote($$system_path($$absolute_path($$1))) return ($$rawPath) } # This function creates the translation .qm files in DEPLOYMENTDIR/translation # @Param: List with all .ts files # @Param example: C://myapp/translations/exampleLanguage.ts defineReplace(createQMFiles){ TRANSLATION_FILES = $$1 fileNames = for(translationElement, TRANSLATION_FILES){ rawTranslations = $$split(translationElement,/) file = $$last(rawTranslations) fileNames += $$file } fileNamesNoEnding = for(fileElement, fileNames){ rawFileNameNoEnding = $$split(fileElement,.) fileNamesNoEnding += $$first(rawFileNameNoEnding) } QM_FILES = for(fileNameNoEnding,fileNamesNoEnding){ QM_FILES += $$fixPath($$join(fileNameNoEnding, .qm, $${DEPLOYMENTDIR}/translations/, .qm)) } LRELEASE = $$[QT_INSTALL_BINS]/lrelease #.exe NEW_TRANSLATIONS = for(entry, TRANSLATION_FILES){ NEW_TRANSLATIONS += $$fixPath($$entry) } for(tsFile, NEW_TRANSLATIONS){ command = $$LRELEASE $${tsFile} -qm $$take_first(QM_FILES) message($$command) system($$command)|error("Failed to run: $$command") } return }
I know that this is a really ugly way to do this. The "clean" way described in link did not work for me. Does anyone have a suggestion to do this in a cleaner way?
more information: I'm using QT version 5.9.7.