WSL/SLF GitLab Repository

Commit c9861055 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Preliminary version that supports translations

parent e9edcd1c
......@@ -59,7 +59,60 @@ IF(APPLE)
SET(DLL_EXT "dylib")
ENDIF(APPLE)
ADD_EXECUTABLE(${TARGET} ${TARGET_TYPE} ${EXTRA_LIBS_SRC} ${SOURCES} ${RESOURCES})
# Generate the .qm translation files and potentially the .ts files
SET(SUPPORT_TRANSLATIONS OFF CACHE BOOL "Support translating the user interface? (this may require the qttools5-dev package)")
IF(SUPPORT_TRANSLATIONS)
FIND_PACKAGE(Qt5LinguistTools REQUIRED)
MARK_AS_ADVANCED(FORCE Qt5LinguistTools_DIR)
SET(REFRESH_TRANSLATION_FILES OFF CACHE BOOL "Regenerate the translation files? (this will overwrite the existing .ts files)")
IF(REFRESH_TRANSLATION_FILES)
qt5_create_translation(QM_FILES ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/resources/langs/inishell_de.ts)
ENDIF(REFRESH_TRANSLATION_FILES)
FILE(GLOB TS_FILES ${PROJECT_SOURCE_DIR}/resources/langs/*.ts)
SET_SOURCE_FILES_PROPERTIES(${TS_FILES} PROPERTIES OUTPUT_LOCATION "resources/l10n")
qt5_add_translation(QM_FILES ${TS_FILES})
# qt5_create_translation(QM_FILES ${PROJECT_SOURCE_DIR} ${TS_FILES} OPTIONS -source-language en_US -no-obsolete)
#SET(TS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/../resources/langs/inishell_de.ts")
# SET_SOURCE_FILES_PROPERTIES(${TS_FILES} PROPERTIES OUTPUT_LOCATION "resources/l10n")
# qt5_add_translation(QM_FILES ${TS_FILES})
# ADD_CUSTOM_TARGET(translations DEPENDS ${QM_FILES})
#
# if(NOT QT_TRANSLATIONS_DIR)
# # If this directory is missing, we are in a Qt5 environment.
# # Extract the qmake executable location
# GET_TARGET_PROPERTY(QT5_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
# # Ask Qt5 where to put the translations
# EXECUTE_PROCESS(COMMAND ${QT5_QMAKE_EXECUTABLE} -query QT_INSTALL_TRANSLATIONS
# OUTPUT_VARIABLE qt_translations_dir OUTPUT_STRIP_TRAILING_WHITESPACE)
# # make sure we have / and not \ as qmake gives on windows
# FILE(TO_CMAKE_PATH "${qt_translations_dir}" qt_translations_dir)
# SET(QT_TRANSLATIONS_DIR ${qt_translations_dir} CACHE PATH "The location of the Qt translations" FORCE)
# endif()
#
# INSTALL(FILES ${QM_FILES} DESTINATION ${QT_TRANSLATIONS_DIR})
# qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/resources/langs/inishell_de.ts)
# qt5_add_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/langs/inishell_de.ts)
# configure_file(translations.qrc ${CMAKE_BINARY_DIR} COPYONLY)
#set(TS_FILES helloworld_en.ts helloworld_de.ts)
# SET_SOURCE_FILES_PROPERTIES(${TS_FILES} PROPERTIES OUTPUT_LOCATION "resources/l10n")
# qt5_add_translation(QM_FILES ${TS_FILES})
# file(GLOB TRANSLATION_FILES ${CMAKE_SOURCE_DIR}/Translations/*.ts)
# qt5_add_translation(QM_FILES ${TRANSLATION_FILES})
ENDIF(SUPPORT_TRANSLATIONS)
ADD_EXECUTABLE(${TARGET} ${TARGET_TYPE} ${EXTRA_LIBS_SRC} ${SOURCES} ${RESOURCES} ${QM_FILES})
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/")
TARGET_LINK_LIBRARIES(${TARGET} ${QT5_LIBRARIES})
......@@ -90,21 +143,11 @@ IF(APPLE)
)
ENDIF(APPLE)
# Generate the qm translation files
SET(GENERATE_TRANSLATION_FILES OFF CACHE BOOL "Generate the translations files? (this may require the qttools5-dev package)")
IF(GENERATE_TRANSLATION_FILES)
FIND_PACKAGE(Qt5LinguistTools REQUIRED) #requires package qttools5-dev on Ubuntu
MARK_AS_ADVANCED(FORCE Qt5LinguistTools_DIR)
SET(TS_FILES ./resources/languages/inishell_de.ts)
SET_SOURCE_FILES_PROPERTIES(${TS_FILES} PROPERTIES OUTPUT_LOCATION "./resources/l10n")
qt5_add_translation(qmFiles ${TS_FILES})
ENDIF(GENERATE_TRANSLATION_FILES)
###########################################################
# Custom targets
ADD_CUSTOM_TARGET(distclean make clean
COMMAND cmake -E remove CMakeCache.txt CPackSourceConfig.cmake CPackConfig.cmake CTestTestfile.cmake DartConfiguration.tcl cmake_install.cmake cmake_uninstall.cmake install_manifest.txt Makefile
COMMAND cmake -E remove bin/inishell bin/inishell.*
COMMAND cmake -E remove bin/inishell bin/inishell.* ${QM_FILES}
COMMAND cmake -E remove */CMakeCache.txt */CTestTestfile.cmake */cmake_install.cmake
COMMAND cmake -E remove */*/CMakeCache.txt */*/CTestTestfile.cmake */*/cmake_install.cmake
COMMAND cmake -E remove_directory CMakeFiles
......
......@@ -34,7 +34,7 @@ OR find icons/ -name "*.svg" | grep "elementary" | awk '{printf("<file>%s</file>
<file>icons/inishell_192.ico</file>
<file>config_schema.xsd</file>
<file>languages/inishell_de.qm</file>
<!-- <file>langs/inishell_de.qm</file>-->
<file>doc/help.xml</file>
<file>doc/help_dev.xml</file>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment