diff --git a/CMakeModules/CalamaresAddTranslations.cmake b/CMakeModules/CalamaresAddTranslations.cmake
index a5e256427..03e655fa4 100644
--- a/CMakeModules/CalamaresAddTranslations.cmake
+++ b/CMakeModules/CalamaresAddTranslations.cmake
@@ -101,15 +101,24 @@ function( install_calamares_gettext_translations )
endforeach()
endfunction()
+set(_calamares_qrc_translations_qrc_source ${CMAKE_CURRENT_LIST_DIR}/i18n.qrc.in) # Needs to be set outside of function
function(calamares_qrc_translations basename)
- set(NAME ${ARGV0})
set(options "")
set(oneValueArgs SUBDIRECTORY OUTPUT_VARIABLE)
- set(multiValueArgs LANGUAGES)
+ set(multiValueArgs PREFIXES LANGUAGES)
cmake_parse_arguments(_qrt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT _qrt_OUTPUT_VARIABLE)
- set(_qrt_OUTPUT_VARIABLE "qrc_translations_${basename}")
+ message(FATAL_ERROR "No output variable")
+ endif()
+ if(NOT _qrt_PREFIXES)
+ set(_qrt_PREFIXES "${basename}")
+ endif()
+ if(NOT _qrt_LANGUAGES)
+ set(_qrt_LANGUAGES ${CALAMARES_TRANSLATION_LANGUAGES})
+ endif()
+ if(NOT _qrt_SUBDIRECTORY)
+ set(_qrt_SUBDIRECTORY "")
endif()
set(translations_qrc_infile ${CMAKE_CURRENT_BINARY_DIR}/${basename}.qrc)
@@ -119,35 +128,30 @@ function(calamares_qrc_translations basename)
set(calamares_i18n_qrc_content "")
set(calamares_i18n_ts_filelist "")
foreach(lang ${_qrt_LANGUAGES})
- string(APPEND calamares_i18n_qrc_content "${basename}_${lang}.qm")
- list(
- APPEND
- calamares_i18n_ts_filelist
- "${CMAKE_CURRENT_SOURCE_DIR}/${_qrt_SUBDIRECTORY}/${basename}_${lang}.ts"
- )
+ foreach(tlsource ${_qrt_PREFIXES})
+ if(EXISTS "${CMAKE_SOURCE_DIR}/{$_qrt_SUBDIRECTORY}/${tlsource}_${lang}.ts")
+ string(APPEND calamares_i18n_qrc_content "${tlsource}_${lang}.qm\n")
+ list(APPEND calamares_i18n_ts_filelist "${CMAKE_SOURCE_DIR}/${_qrt_SUBDIRECTORY}/${tlsource}_${lang}.ts")
+ endif()
+ endforeach()
endforeach()
- configure_file(${CMAKE_SOURCE_DIR}/lang/calamares_i18n.qrc.in ${translations_qrc_infile} @ONLY)
+ configure_file(${_calamares_qrc_translations_qrc_source} ${translations_qrc_infile} @ONLY)
qt_add_translation(QM_FILES ${calamares_i18n_ts_filelist})
- if(WITH_QT6)
- # Simplified build, knows about RCC
- set(${_qrt_OUTPUT_VARIABLE} ${translations_qrc_infile} PARENT_SCOPE)
- else()
- # Run the resource compiler (rcc_options should already be set)
- add_custom_command(
- OUTPUT ${translations_qrc_outfile}
- COMMAND "${Qt5Core_RCC_EXECUTABLE}"
- ARGS
- ${rcc_options}
- --format-version 1
- -name ${basename}
- -o ${translations_qrc_outfile}
- ${translations_qrc_infile}
- MAIN_DEPENDENCY ${translations_qrc_infile}
- DEPENDS ${QM_FILES}
- )
+ # Run the resource compiler (rcc_options should already be set)
+ add_custom_command(
+ OUTPUT ${translations_qrc_outfile}
+ COMMAND ${qtname}::rcc
+ ARGS
+ ${rcc_options}
+ --format-version 1
+ -name ${basename}
+ -o ${translations_qrc_outfile}
+ ${translations_qrc_infile}
+ MAIN_DEPENDENCY ${translations_qrc_infile}
+ DEPENDS ${QM_FILES}
+ )
- set(${_qrt_OUTPUT_VARIABLE} ${translations_qrc_outfile} PARENT_SCOPE)
- endif()
+ set(${_qrt_OUTPUT_VARIABLE} ${translations_qrc_outfile} PARENT_SCOPE)
endfunction()
diff --git a/lang/calamares_i18n.qrc.in b/CMakeModules/i18n.qrc.in
similarity index 100%
rename from lang/calamares_i18n.qrc.in
rename to CMakeModules/i18n.qrc.in
diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt
index fc3a1db1e..dd2a47b04 100644
--- a/lang/CMakeLists.txt
+++ b/lang/CMakeLists.txt
@@ -30,35 +30,9 @@ install_calamares_gettext_translations(python
### TRANSLATIONS
#
#
-set(TS_FILES "")
-set(calamares_i18n_qrc_content "")
-
-# calamares and qt language files
-foreach(lang ${CALAMARES_TRANSLATION_LANGUAGES})
- foreach(tlsource "calamares_${lang}" "tz_${lang}" "kb_${lang}")
- if(EXISTS "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts")
- string(APPEND calamares_i18n_qrc_content "${tlsource}.qm\n")
- list(APPEND TS_FILES "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts")
- endif()
- endforeach()
-endforeach()
-
-set(trans_file calamares_i18n)
-set(trans_infile ${CMAKE_CURRENT_BINARY_DIR}/${trans_file}.qrc)
-set(trans_outfile ${CMAKE_CURRENT_BINARY_DIR}/calamares-i18n.cxx)
-set(CALAMARES_TRANSLATIONS_SOURCE ${trans_outfile})
-
-configure_file(${CMAKE_SOURCE_DIR}/lang/calamares_i18n.qrc.in ${trans_infile} @ONLY)
-
-qt_add_translation(QM_FILES ${TS_FILES})
-
-# Run the resource compiler (rcc_options should already be set)
-add_custom_command(
- OUTPUT ${trans_outfile}
- COMMAND "${Qt5Core_RCC_EXECUTABLE}"
- ARGS ${rcc_options} --format-version 1 -name ${trans_file} -o ${trans_outfile} ${trans_infile}
- MAIN_DEPENDENCY ${trans_infile}
- DEPENDS ${QM_FILES}
+calamares_qrc_translations(calamares-i18n
+ OUTPUT_VARIABLE translation_outfile
+ PREFIXES calamares tz kb
)
-add_library(calamares-i18n OBJECT ${trans_outfile})
+add_library(calamares-i18n OBJECT ${translation_outfile})