From 55dfd70e043a709256e86b06f34037085ac431fe Mon Sep 17 00:00:00 2001 From: kradchen Date: Thu, 5 Jun 2025 14:42:00 +0800 Subject: [PATCH] feat: add language translate cmake logic --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65a4486..7475d71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,11 +45,16 @@ if(ENABLE_QT) file(GLOB_RECURSE project_uis ./src/*.ui) qt5_wrap_ui(ui_FILES ${project_uis}) file(GLOB project_res ./src/*.qrc) - + set(TS_FILES + ./src/translations/en_US.ts + ./src/translations/zh_CN.ts) + find_package(Qt5 COMPONENTS ${REQUIRED_LIBS} LinguistTools REQUIRED) + set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${CMAKE_SOURCE_DIR}/src/translations) + qt5_create_translation(QM_FILES ${project_cpps} ${project_cxx} ${ui_FILES} ${TS_FILES}) source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${project_uis}) source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${project_res}) - add_executable(${PROJECT_NAME} ${project_headers} ${project_cpps} ${project_cxx} ${project_res} ${project_cc} ${ui_FILES}) + add_executable(${PROJECT_NAME} ${project_headers} ${project_cpps} ${project_cxx} ${project_res} ${project_cc} ${ui_FILES} ${QM_FILES} ) target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets Qt5::Gui Qt5::OpenGL) else(ENABLE_QT)