diff --git a/cmake/modules/LXQtTranslateTs.cmake b/cmake/modules/LXQtTranslateTs.cmake index 3b2536a..7c8c344 100644 --- a/cmake/modules/LXQtTranslateTs.cmake +++ b/cmake/modules/LXQtTranslateTs.cmake @@ -26,10 +26,8 @@ #============================================================================= # # funtion lxqt_translate_ts(qmFiles -# [USE_QT5 [Yes | No]] # [UPDATE_TRANSLATIONS [Yes | No]] # SOURCES -# [UPDATE_OPTIONS] update_options # [TEMPLATE] translation_template # [TRANSLATION_DIR] translation_directory # [INSTALL_DIR] install_directory @@ -39,15 +37,10 @@ # qmFiles The generated compiled translations (.qm) files # # Input: -# USE_QT5 Optional flag to choose between Qt4 and Qt5. Defaults to Qt5 -# # UPDATE_TRANSLATIONS Optional flag. Setting it to Yes, extracts and # compiles the translations. Setting it No, only # compiles them. # -# UPDATE_OPTIONS Optional options to lupdate when UPDATE_TRANSLATIONS -# is True. -# # TEMPLATE Optional translations files base name. Defaults to # ${PROJECT_NAME}. An .ts extensions is added. # @@ -67,28 +60,19 @@ include(Qt5PatchedLinguistToolsMacros) function(lxqt_translate_ts qmFiles) set(oneValueArgs - USE_QT5 UPDATE_TRANSLATIONS TEMPLATE TRANSLATION_DIR INSTALL_DIR COMPONENT ) - set(multiValueArgs SOURCES UPDATE_OPTIONS) + set(multiValueArgs SOURCES) cmake_parse_arguments(TR "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) if (NOT DEFINED TR_UPDATE_TRANSLATIONS) set(TR_UPDATE_TRANSLATIONS "No") endif() - if (NOT DEFINED TR_UPDATE_OPTIONS) - set(TR_UPDATE_OPTIONS "") - endif() - - if (NOT DEFINED TR_USE_QT5) - set(TR_USE_QT5 "Yes") - endif() - if(NOT DEFINED TR_TEMPLATE) set(TR_TEMPLATE "${PROJECT_NAME}") endif() @@ -103,43 +87,16 @@ function(lxqt_translate_ts qmFiles) set(templateFile "${TR_TRANSLATION_DIR}/${TR_TEMPLATE}.ts") endif () - if(TR_USE_QT5) - # Qt5 - if (TR_UPDATE_TRANSLATIONS) - qt5_patched_create_translation(QMS - ${TR_SOURCES} - ${templateFile} - OPTIONS ${TR_UPDATE_OPTIONS} - ) - qt5_patched_create_translation(QM - ${TR_SOURCES} - ${tsFiles} - OPTIONS ${TR_UPDATE_OPTIONS} - ) - else() - qt5_patched_add_translation(QM ${tsFiles}) - endif() - else() - # Qt4 - if(TR_UPDATE_TRANSLATIONS) - qt4_create_translation(QMS - ${TR_SOURCES} - ${templateFile} - OPTIONS ${TR_UPDATE_OPTIONS} - ) - qt4_create_translation(QM - ${TR_SOURCES} - ${tsFiles} - OPTIONS ${TR_UPDATE_OPTIONS} - ) - else() - qt4_add_translation(QM ${tsFiles}) - endif() - endif() - - if(TR_UPDATE_TRANSLATIONS) - add_custom_target("update_${TR_TEMPLATE}_ts" ALL DEPENDS ${QMS}) + if (TR_UPDATE_TRANSLATIONS) + message("Running lxqt-transupdate: ") + execute_process( + COMMAND lxqt-transupdate + WORKING_DIRECTORY .. + OUTPUT_VARIABLE outVar + ) + message(${outVar}) endif() + qt5_patched_add_translation(QM ${tsFiles}) if(DEFINED TR_INSTALL_DIR) if(NOT DEFINED TR_COMPONENT) diff --git a/cmake/modules/Qt5PatchedLinguistToolsMacros.cmake b/cmake/modules/Qt5PatchedLinguistToolsMacros.cmake index e5c2f5c..1f5bcf0 100644 --- a/cmake/modules/Qt5PatchedLinguistToolsMacros.cmake +++ b/cmake/modules/Qt5PatchedLinguistToolsMacros.cmake @@ -32,59 +32,6 @@ include(CMakeParseArguments) -function(QT5_PATCHED_CREATE_TRANSLATION _qm_files) - set(options) - set(oneValueArgs) - set(multiValueArgs OPTIONS) - - cmake_parse_arguments(_LUPDATE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - set(_lupdate_files ${_LUPDATE_UNPARSED_ARGUMENTS}) - set(_lupdate_options ${_LUPDATE_OPTIONS}) - - set(_my_sources) - set(_my_tsfiles) - foreach(_file ${_lupdate_files}) - get_filename_component(_ext ${_file} EXT) - get_filename_component(_abs_FILE ${_file} ABSOLUTE) - if(_ext MATCHES "ts") - list(APPEND _my_tsfiles ${_abs_FILE}) - else() - list(APPEND _my_sources ${_abs_FILE}) - endif() - endforeach() - foreach(_ts_file ${_my_tsfiles}) - if(_my_sources) - # make a list file to call lupdate on, so we don't make our commands too - # long for some systems -# get_filename_component(_ts_name ${_ts_file} NAME_WE) - - get_filename_component(_name ${_ts_file} NAME) - string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _ts_name ${_name}) - - set(_ts_lst_file "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lst_file") - set(_lst_file_srcs) - foreach(_lst_file_src ${_my_sources}) - set(_lst_file_srcs "${_lst_file_src}\n${_lst_file_srcs}") - endforeach() - - get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES) - foreach(_pro_include ${_inc_DIRS}) - get_filename_component(_abs_include "${_pro_include}" ABSOLUTE) - set(_lst_file_srcs "-I${_pro_include}\n${_lst_file_srcs}") - endforeach() - - file(WRITE ${_ts_lst_file} "${_lst_file_srcs}") - endif() - add_custom_command(OUTPUT ${_ts_file} - COMMAND ${Qt5_LUPDATE_EXECUTABLE} - ARGS ${_lupdate_options} "@${_ts_lst_file}" -ts ${_ts_file} - DEPENDS ${_my_sources} ${_ts_lst_file} VERBATIM) - endforeach() - qt5_patched_add_translation(${_qm_files} ${_my_tsfiles}) - set(${_qm_files} ${${_qm_files}} PARENT_SCOPE) -endfunction() - - function(QT5_PATCHED_ADD_TRANSLATION _qm_files) foreach(_current_FILE ${ARGN}) get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)