Fix translations (and simplify resource files)

qt66
Nicolas Werner 1 year ago
parent ca0340dd81
commit 05f1f8f556
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
  1. 17
      CMakeLists.txt
  2. 28
      cmake/Translations.cmake

@ -633,10 +633,13 @@ if (NOT APPLE AND NOT WIN32)
endif() endif()
# #
# Bundle translations. # Bundle resources
# #
include(Translations) if(Qt6QuickCompiler_FOUND AND COMPILE_QML)
set(TRANSLATION_DEPS ${LANG_QRC} ${QRC} ${QM_SRC}) qtquick_compiler_add_resources(QRC resources/res.qrc)
else()
qt_add_resources(QRC resources/res.qrc)
endif()
if (APPLE) if (APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Foundation -framework Cocoa -framework UserNotifications") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Foundation -framework Cocoa -framework UserNotifications")
@ -668,7 +671,7 @@ endif ()
set(NHEKO_DEPS set(NHEKO_DEPS
${SRC_FILES} ${SRC_FILES}
${TRANSLATION_DEPS} ${QRC}
${META_FILES_TO_INCLUDE}) ${META_FILES_TO_INCLUDE})
if(ASAN) if(ASAN)
@ -691,6 +694,12 @@ set_target_properties(nheko
CMAKE_SKIP_INSTALL_RPATH TRUE CMAKE_SKIP_INSTALL_RPATH TRUE
AUTOMOC ON) AUTOMOC ON)
#
# Bundle translations
#
file(GLOB LANG_TS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/resources/langs/*.ts")
qt_add_translations(nheko RESOURCE_PREFIX "/translations" TS_FILES ${LANG_TS_SRC})
if(WIN32) if(WIN32)
target_compile_definitions(nheko PRIVATE WIN32_LEAN_AND_MEAN) target_compile_definitions(nheko PRIVATE WIN32_LEAN_AND_MEAN)
if(MSVC) if(MSVC)

@ -1,28 +0,0 @@
#
# Generate the translation resource file
#
file(GLOB LANG_TS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/resources/langs/*.ts")
qt_add_translation(QM_SRC ${LANG_TS_SRC})
qt_create_translation(${QM_SRC})
add_custom_target(LANG_QRC ALL DEPENDS ${QM_SRC})
# Generate a qrc file for the translations
set(_qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
if(NOT EXISTS ${_qrc})
file(WRITE ${_qrc} "<RCC>\n <qresource prefix=\"/translations\">\n")
foreach(_lang ${QM_SRC})
get_filename_component(_filename ${_lang} NAME)
file(APPEND ${_qrc} " <file>${_filename}</file>\n")
endforeach(_lang)
file(APPEND ${_qrc} " </qresource>\n</RCC>\n")
endif()
qt_add_resources(LANG_QRC ${_qrc})
if(Qt5QuickCompiler_FOUND AND COMPILE_QML)
qtquick_compiler_add_resources(QRC resources/res.qrc)
else()
qt_add_resources(QRC resources/res.qrc)
endif()
Loading…
Cancel
Save