[vlmc-devel] cmake: Re-enable translations
Hugo Beauzée-Luyssen
git at videolan.org
Fri Apr 1 23:56:09 CEST 2016
vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Apr 1 22:42:19 2016 +0200| [4f8b12ddc8cb5348b14e6526682517731ac965b1] | committer: Hugo Beauzée-Luyssen
cmake: Re-enable translations
This should also properly fix #16 & #19
> https://code.videolan.org/videolan/vlmc/commit/4f8b12ddc8cb5348b14e6526682517731ac965b1
---
CMakeLists.txt | 2 +-
src/CMakeLists.txt | 5 +-
ts/CMakeLists.txt | 136 ++++++++++++++++++++++++-----------------------------
3 files changed, 66 insertions(+), 77 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f75176f..cde5855 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -164,7 +164,7 @@ IF (UNIX)
SET (VLMC_MANUAL_DIR ${CMAKE_INSTALL_PREFIX}/${VLMC_MANUAL_SUBDIR})
ENDIF (UNIX)
-# SUBDIRS(ts)
+include(ts/CMakeLists.txt)
SUBDIRS(src)
SUBDIRS(nsis)
SUBDIRS(effects)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c8210cc..dc5e0d7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -213,6 +213,8 @@ ELSE(NOT WITH_GUI)
qt5_wrap_ui(VLMC_UIS_H ${VLMC_UIS})
qt5_add_resources(VLMC_RCC_SRCS ${VLMC_RCC})
+ vlmc_get_ts(VLMC_QMS)
+
IF( MINGW )
# resource compilation for MinGW
ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/icon.o
@@ -240,7 +242,7 @@ ELSE(NOT WITH_GUI)
LIST( APPEND VLMC_SRCS Gui/preview/RenderWidget.h )
ENDIF( APPLE )
- ADD_EXECUTABLE( vlmc ${GUI_TYPE} ${VLMC_SRCS} ${VLMC_MOC_SRCS} ${VLMC_UIS_H} ${VLMC_RCC_SRCS} )
+ ADD_EXECUTABLE( vlmc ${GUI_TYPE} ${VLMC_SRCS} ${VLMC_MOC_SRCS} ${VLMC_UIS_H} ${VLMC_RCC_SRCS} ${VLMC_QMS} )
TARGET_LINK_LIBRARIES( vlmc ${VLMC_LIBS} )
if (NOT Qt4_FOUND)
qt5_use_modules(vlmc Core Gui Widgets Xml Network)
@@ -249,7 +251,6 @@ ELSE(NOT WITH_GUI)
# We could hide this command in qt_use_modules macro, but this would be some kind of black magic uglyness
TARGET_LINK_LIBRARIES(vlmc ${QT_LIBRARIES})
endif()
-
ENDIF( NOT WITH_GUI )
#ADD_DEPENDENCIES( vlmc translations )
diff --git a/ts/CMakeLists.txt b/ts/CMakeLists.txt
index a9ad4b5..be2025a 100644
--- a/ts/CMakeLists.txt
+++ b/ts/CMakeLists.txt
@@ -2,86 +2,74 @@
# VLMC build system
# Authors: Ludovic Fauvet <etix at vlmc.org>
# Rohit Yadav <rohityadav89 at gmail.com>
+# Hugo Beauzée-Luyssen <hugo at beauzee.fr>
#
cmake_minimum_required(VERSION 3.1)
-## RCC file
-SET(TS_QRC ${CMAKE_SOURCE_DIR}/ts/resources-ts.qrc)
-if(Qt5LinguistTools_FOUND)
+function(vlmc_get_ts_files VLMC_TS_FILES_OUT)
+ SET(ALL_LANGUAGES
+ ca
+ cs
+ de
+ es
+ eu
+ fr
+ gl
+ el
+ hu
+ it
+ ja
+ nl
+ pl
+ pt
+ ro
+ ru
+ sl
+ sk
+ sv
+ ta
+ te
+ tr
+ uk
+ zh
+ )
-# Don't remove TS files on make clean.
-set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1)
+ ## Check if user has provided specific LANGS option
+ if(NOT DEFINED LANGS)
+ SET(VLMC_USING_LANGUAGES ${ALL_LANGUAGES} CACHE STRING "Using translations" FORCE)
+ else(NOT DEFINED LANGS)
+ IF(NOT LANGS)
+ SET(VLMC_USING_LANGUAGES "" CACHE STRING "Using translations" FORCE)
+ ELSEIF(LANGS STREQUAL *)
+ SET(VLMC_USING_LANGUAGES ${ALL_LANGUAGES} CACHE STRING "Using translations" FORCE)
+ ELSE(NOT LANGS)
+ STRING(REGEX MATCHALL [a-zA-Z_]+
+ langs1 ${LANGS})
+ SET(VLMC_USING_LANGUAGES ${langs1} CACHE STRING "Using translations" FORCE)
+ ENDIF(NOT LANGS)
+ endif(NOT DEFINED LANGS)
-## Set availbale translations file ids here
-OPTION(LANGUAGES "Using translations")
-SET(ALL_LANGUAGES
- ca
- cs
- de
- es
- eu
- fr
- gl
- el
- hu
- it
- ja
- nl
- pl
- pt
- ro
- ru
- sl
- sk
- sv
- ta
- te
- tr
- uk
- zh
- )
+ ## Display what translations files will be processed
+ MESSAGE(STATUS "Translations: ${VLMC_USING_LANGUAGES}")
-## Check if user has provided specific LANGS option
-IF(NOT DEFINED LANGS)
- SET(LANGUAGES ${ALL_LANGUAGES} CACHE STRING "Using translations" FORCE)
-ELSE(NOT DEFINED LANGS)
- IF(NOT LANGS)
- SET(LANGUAGES "" CACHE STRING "Using translations" FORCE)
- ELSEIF(LANGS STREQUAL *)
- SET(LANGUAGES ${ALL_LANGUAGES} CACHE STRING "Using translations" FORCE)
- ELSE(NOT LANGS)
- STRING(REGEX MATCHALL [a-zA-Z_]+
- langs1 ${LANGS})
- SET(LANGUAGES ${langs1} CACHE STRING "Using translations" FORCE)
- ENDIF(NOT LANGS)
-ENDIF(NOT DEFINED LANGS)
+ ## Collect all translations files that are to be processed
+ FOREACH(LANGUAGE ${VLMC_USING_LANGUAGES})
+ FILE(GLOB temp_TS ${CMAKE_SOURCE_DIR}/ts/vlmc*${LANGUAGE}*.ts)
+ LIST(APPEND VLMC_TS_FILES ${temp_TS})
+ ENDFOREACH()
+ set(${VLMC_TS_FILES_OUT} ${VLMC_TS_FILES} PARENT_SCOPE)
+endfunction()
-## Display what translations files will be processed
-MESSAGE(STATUS "Translations: ${LANGUAGES}")
+function(vlmc_get_ts VLMC_QM_FILES_OUT)
+ if(Qt5LinguistTools_FOUND)
+ vlmc_get_ts_files(vlmc_TS)
-## Collect all translations files that are to be processed
-FOREACH(LANGUAGE ${LANGUAGES})
- FILE(GLOB temp_TS ${CMAKE_SOURCE_DIR}/ts/vlmc*${LANGUAGE}*.ts)
- LIST(APPEND vlmc_TS ${temp_TS})
-ENDFOREACH()
-
-## Wraps the collected translations
-qt5_add_translation(vlmc_QMS ${vlmc_TS})
-
-## Create a target that runs lrelease for all the .ts files
-## "ALL" means that it will be run by default.
-ADD_CUSTOM_TARGET(translations ALL DEPENDS ${vlmc_QMS})
-
-## Search for all translatable strings in the sources directory
-qt5_create_translation(vlmc_TS_UPDATE ${CMAKE_SOURCE_DIR}/src ${vlmc_TS})
-
-## Create a target that runs lupdate for all the sources and UI files
-message(STATUS "ts: ${vlmc_TS_UPDATE}")
-ADD_CUSTOM_TARGET(lupdate DEPENDS ${vlmc_TS_UPDATE})
-
-else()
- MESSAGE(WARNING "VLMC could not find Qt5 linguist tools. i18n support will be disabled.")
- ## Create an empty RCC file
- FILE(WRITE ${TS_QRC} "<RCC></RCC>")
-endif()
+ ## Wraps the collected translations
+ qt5_add_translation(VLMC_QM_FILES ${vlmc_TS})
+ set(${VLMC_QM_FILES_OUT} ${VLMC_QM_FILES} PARENT_SCOPE)
+ else()
+ MESSAGE(WARNING "VLMC could not find Qt5 linguist tools. i18n support will be disabled.")
+ set(${VLMC_QM_FILES_OUT} "" PARENT_SCOPE)
+ endif()
+endfunction()
More information about the Vlmc-devel
mailing list