@@ -69,6 +69,9 @@ add_custom_command(
6969)
7070set_source_files_properties (${GENERATED_SRC_WIZARD} /configdoc.cpp PROPERTIES GENERATED 1 )
7171
72+ # Localized config.xml files are manually placed in ${PROJECT_SOURCE_DIR}/src/translations
73+ # They are referenced directly in doxywizard.qrc
74+
7275set (LEX_FILES config_doxyw)
7376
7477if (NOT depfile_supported)
@@ -140,10 +143,63 @@ inputbool.h
140143inputstring.h
141144inputstrlist.h
142145wizard.h
146+ translationmanager.h
143147)
144148
145149qt_add_resources (doxywizard_RESOURCES_RCC doxywizard.qrc )
146150
151+ # Generate localized config.qrc
152+ set (CONFIG_QRC_CONTENT "<!DOCTYPE RCC>\n <RCC version=\" 1.0\" >\n <qresource prefix=\" /config\" >\n " )
153+ string (APPEND CONFIG_QRC_CONTENT " <file alias=\" config.xml\" >${PROJECT_SOURCE_DIR} /src/config.xml</file>\n " )
154+ file (GLOB LANG_CONFIG_FILES CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR} /src/translations/config_*.xml" )
155+ foreach (lang_file ${LANG_CONFIG_FILES} )
156+ get_filename_component (lang_name "${lang_file} " NAME ) # e.g. config_zh_CN.xml
157+ string (APPEND CONFIG_QRC_CONTENT " <file alias=\" ${lang_name} \" >${lang_file} </file>\n " )
158+ endforeach ()
159+ string (APPEND CONFIG_QRC_CONTENT "</qresource>\n </RCC>\n " )
160+
161+ file (GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR} /config.qrc
162+ CONTENT ${CONFIG_QRC_CONTENT}
163+ )
164+
165+ qt_add_resources (doxywizard_CONFIG_RESOURCES ${CMAKE_CURRENT_BINARY_DIR} /config.qrc )
166+
167+ set (TRANSLATIONS_DIR ${CMAKE_CURRENT_SOURCE_DIR} /translations)
168+
169+ file (GLOB DOXYWIZARD_TRANSLATION_FILES CONFIGURE_DEPENDS "${TRANSLATIONS_DIR} /doxywizard_*.ts" )
170+
171+ set (ALL_TRANSLATION_FILES
172+ ${DOXYWIZARD_TRANSLATION_FILES}
173+ )
174+
175+ find_package (Qt6LinguistTools QUIET )
176+ if (Qt6LinguistTools_FOUND)
177+ set_source_files_properties (${ALL_TRANSLATION_FILES} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR} )
178+ qt6_add_translation (doxywizard_QM_FILES ${ALL_TRANSLATION_FILES} )
179+ else ()
180+ find_package (Qt5LinguistTools QUIET )
181+ if (Qt5LinguistTools_FOUND)
182+ set_source_files_properties (${ALL_TRANSLATION_FILES} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR} )
183+ qt5_add_translation (doxywizard_QM_FILES ${ALL_TRANSLATION_FILES} )
184+ else ()
185+ set (doxywizard_QM_FILES)
186+ message (STATUS "Qt Linguist tools not found, translation files will not be compiled" )
187+ endif ()
188+ endif ()
189+
190+ set (TRANSLATIONS_QRC_CONTENT "<!DOCTYPE RCC>\n <RCC version=\" 1.0\" >\n <qresource prefix=\" /translations\" >\n " )
191+ foreach (qm_file ${doxywizard_QM_FILES} )
192+ get_filename_component (qm_name ${qm_file} NAME )
193+ string (APPEND TRANSLATIONS_QRC_CONTENT " <file>${qm_name} </file>\n " )
194+ endforeach ()
195+ string (APPEND TRANSLATIONS_QRC_CONTENT " </qresource>\n </RCC>\n " )
196+
197+ file (GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR} /translations.qrc
198+ CONTENT ${TRANSLATIONS_QRC_CONTENT}
199+ )
200+
201+ qt_add_resources (doxywizard_TRANSLATION_RESOURCES ${CMAKE_CURRENT_BINARY_DIR} /translations.qrc )
202+
147203add_executable (doxywizard WIN32
148204config_msg.cpp
149205doxywizard.cpp
@@ -153,12 +209,16 @@ inputbool.cpp
153209inputstring.cpp
154210inputint.cpp
155211inputstrlist.cpp
212+ translationmanager.cpp
156213${GENERATED_SRC_WIZARD} /settings.h
157214${GENERATED_SRC_WIZARD} /config_doxyw.cpp
158215${GENERATED_SRC_WIZARD} /config_doxyw.l.h
159216${GENERATED_SRC_WIZARD} /configdoc.cpp
160217${doxywizard_MOC}
161218${doxywizard_RESOURCES_RCC}
219+ ${doxywizard_CONFIG_RESOURCES}
220+ ${doxywizard_TRANSLATION_RESOURCES}
221+ ${doxywizard_QM_FILES}
162222${PROJECT_SOURCE_DIR} /templates/icon/doxygen.rc
163223)
164224
0 commit comments