From 3dc184133f2ff2cde219dba306db105d7f1eb237 Mon Sep 17 00:00:00 2001 From: Serein <2075337935@qq.com> Date: Wed, 25 Sep 2024 21:07:41 +0800 Subject: [PATCH] fix: package locale files location --- CMakeLists.txt | 5 +++++ src/CMakeLists.txt | 8 ++++---- src/Infrastructure/Utils/Config.h | 7 ++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c29bee80..c6182b60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,9 @@ if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/3rdpart/sast-link-cxx-sdk/CMakeLists message(FATAL_ERROR "Git submodule not found. Run `git submodule update --init` from the source tree to fetch the submodule contents.") endif() +#i18n +set(SOURCE_LOCALE_DIR "${CMAKE_SOURCE_DIR}/ui/locale") + # source code add_subdirectory(src) # sast-link-sdk @@ -78,6 +81,8 @@ set(BUILD_SHARED_LIBS ON) file(WRITE ${CMAKE_BINARY_DIR}/sast-evento-version.txt ${VERSION_SEMANTIC}) install(FILES ${CMAKE_BINARY_DIR}/sast-evento-version.txt DESTINATION .) install(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION .) +install(FILES ${SOURCE_LOCALE_DIR}/en/LC_MESSAGES/sast-evento.mo DESTINATION ./locale/en/LC_MESSAGES) +install(FILES ${SOURCE_LOCALE_DIR}/zh/LC_MESSAGES/sast-evento.mo DESTINATION ./locale/zh/LC_MESSAGES) install(TARGETS ${PROJECT_NAME} BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 21c4c322..ce4238f9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -78,10 +78,10 @@ if (WIN32) endif() add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/ui/locale/en/LC_MESSAGES - COMMAND msgfmt ${CMAKE_SOURCE_DIR}/ui/locale/en.po -o ${CMAKE_SOURCE_DIR}/ui/locale/en/LC_MESSAGES/sast-evento.mo - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/ui/locale/en/LC_MESSAGES - COMMAND msgfmt ${CMAKE_SOURCE_DIR}/ui/locale/zh.po -o ${CMAKE_SOURCE_DIR}/ui/locale/zh/LC_MESSAGES/sast-evento.mo + COMMAND ${CMAKE_COMMAND} -E make_directory ${SOURCE_LOCALE_DIR}/en/LC_MESSAGES + COMMAND msgfmt ${SOURCE_LOCALE_DIR}/en.po -o ${SOURCE_LOCALE_DIR}/en/LC_MESSAGES/sast-evento.mo + COMMAND ${CMAKE_COMMAND} -E make_directory ${SOURCE_LOCALE_DIR}/zh/LC_MESSAGES + COMMAND msgfmt ${SOURCE_LOCALE_DIR}/zh.po -o ${SOURCE_LOCALE_DIR}/zh/LC_MESSAGES/sast-evento.mo ) add_subdirectory(Tray) diff --git a/src/Infrastructure/Utils/Config.h b/src/Infrastructure/Utils/Config.h index a634823a..1463d47f 100644 --- a/src/Infrastructure/Utils/Config.h +++ b/src/Infrastructure/Utils/Config.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -39,11 +40,7 @@ const std::filesystem::path localePath = #ifdef EVENTO_DEBUG LOCALE_DIR; #else -#ifdef PLATFORM_LINUX - std::filesystem::path("/usr/share/locale"); -#else - std::filesystem::current_path() / "locale"; -#endif // PLATFORM_LINUX + boost::dll::program_location().parent_path() / "locale"; #endif // EVENTO_DEBUG inline struct Settings {