diff --git a/CoreApp/CMakeLists.txt b/CoreApp/CMakeLists.txt index 9d7d59834133261e5e932da0f63152d73bcc3978..481c404b636b8774f059651c02a0277e56d00d98 100644 --- a/CoreApp/CMakeLists.txt +++ b/CoreApp/CMakeLists.txt @@ -89,28 +89,11 @@ if (APPLE) ) endif () - -set (COREAPP_FILES_TO_TRANSLATE ${COREAPP_FILES_TO_TRANSLATE} ${sources} ${ui} ${headers}) - -# generate/use translation files -# run with UPDATE_TRANSLATIONS set to on to build qm files -option (UPDATE_TRANSLATIONS "Update source translation translations/CoreApp_de_DE.ts files (WARNING: make clean will delete the source .ts files! Danger!)") -if (UPDATE_TRANSLATIONS) - qt4_create_translation(QM_FILES ${COREAPP_FILES_TO_TRANSLATE} translations/CoreApp_de_DE.ts ) -else (UPDATE_TRANSLATIONS) - qt4_add_translation(QM_FILES translations/CoreApp_de_DE.ts ) -endif (UPDATE_TRANSLATIONS) - -# create a target for the translation files ( and object files ) -# Use this target, to update only the translations -add_custom_target (translations_target_core DEPENDS ${QM_FILES}) - -# Build translations with the application -add_dependencies(OpenFlipper translations_target_core ) - -# Copy all translation files after build -of_copy_translations( OpenFlipper ) - +# Translations +set (trans_files ${sources}) +list (APPEND trans_files ${ui}) +list (APPEND trans_files ${headers}) +acg_add_translations (OpenFlipper "de_DE" "${trans_files}") # copy all needed files to "Build" directory to allow a direct execution from it diff --git a/PluginLib/CMakeLists.txt b/PluginLib/CMakeLists.txt index a31b22019fa052f5f66a9ce9533726e6571043c7..7ee3c88fad361f33d41cf562e3d6008d5f9da4a0 100644 --- a/PluginLib/CMakeLists.txt +++ b/PluginLib/CMakeLists.txt @@ -55,25 +55,10 @@ acg_qt4_automoc (moc_targets ${headers}) acg_add_library (PluginLib SHARED ${uic_targets} ${sources} ${headers} ${moc_targets}) -set (PLUGINLIB_FILES_TO_TRANSLATE ${PLUGINLIB_FILES_TO_TRANSLATE} ${sources} ${ui} ${headers}) -# generate/use translation files -# run with UPDATE_TRANSLATIONS set to on to build qm files -option (UPDATE_TRANSLATIONS "Update source translation translations/PluginLib_de_DE.ts files (WARNING: make clean will delete the source .ts files! Danger!)") -if (UPDATE_TRANSLATIONS) - qt4_create_translation(QM_FILES ${PLUGINLIB_FILES_TO_TRANSLATE} translations/PluginLib_de_DE.ts ) -else (UPDATE_TRANSLATIONS) - qt4_add_translation(QM_FILES translations/PluginLib_de_DE.ts ) -endif (UPDATE_TRANSLATIONS) - -# create a target for the translation files ( and object files ) -# Use this target, to update only the translations -add_custom_target (translations_target_pluginlib DEPENDS ${QM_FILES}) - -# Build translations with the application -add_dependencies( PluginLib translations_target_pluginlib ) - -# Copy all translation files after build -of_copy_translations( PluginLib ) +set (trans_files ${sources}) +list (APPEND trans_files ${ui}) +list (APPEND trans_files ${headers}) +acg_add_translations (PluginLib "de_DE" "${trans_files}") target_link_libraries (PluginLib OpenMeshCore diff --git a/cmake/common.cmake b/cmake/common.cmake index 48c046aece41f65543e035fdd35c8001c1292689..cbc85c6f43f92b87bfbec6ef3161f5900d5b08ad 100644 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -32,20 +32,6 @@ macro (acg_modify_project_dirs) endif () endmacro () -# function to copy all translation files from one directory to the OpenFlipper translation directory -# parameters: BuildTarget .. The command will be executed after the target is build -function ( of_copy_translations _target) - - file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Translations ) - - add_custom_command (TARGET ${_target} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E - copy_if_different - ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/*.qm - ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Translations/ ) - -endfunction () - # search all plugins and add them to build function (of_add_plugins) file ( diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 29e96c90e04fe541f960fba1b587370215994f6b..1d2efa4443d0ba61d57960c0aa8e8a4c2771c936 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -10,6 +10,8 @@ # [INCDIRS dir1 dir2 ...] # [ADDSRC file1 file2 ...] # [INSTALLDATA dir1 dir2 ...] +# [TRANSLATION_LANGUAGES lang1 lang2 ...] +# [TRANSLATION_ADDFILES file1 file2 ...] # [LICENSEMANAGER]) # # DIRS = additional directories with source files @@ -23,6 +25,9 @@ # ADDSRC = additional source files # INSTALLDATA = directories that will be installed into the openflipper data directory # +# TRANSLATION_LANGUAGES = language codes for translation +# TRANSLATION_ADDFILES = additional files that should be included into the translation files +# # LICENSEMANAGER = Compile plugin with license management # # Plugins can implement a acg_list_filter ("listname") macro to filter out @@ -41,7 +46,7 @@ endmacro () # parse plugin macro parameter macro (_get_plugin_parameters _prefix) set (_current_var _foo) - set (_supported_var DIRS DEPS OPTDEPS LDFLAGSADD CFLAGSADD LIBRARIES LIBDIRS INCDIRS ADDSRC INSTALLDATA) + set (_supported_var DIRS DEPS OPTDEPS LDFLAGSADD CFLAGSADD LIBRARIES LIBDIRS INCDIRS ADDSRC INSTALLDATA TRANSLATION_LANGUAGES TRANSLATION_ADDFILES) set (_supported_flags LICENSEMANAGER) foreach (_val ${_supported_var}) set (${_prefix}_${_val}) @@ -310,6 +315,14 @@ function (_build_openflipper_plugin plugin) endif () endforeach () + if (${${_PLUGIN}_TRANSLATION_LANGUAGES}) + set (trans_files ${uic_targets}) + list (APPEND trans_files ${sources}) + list (APPEND trans_files ${headers}) + list (APPEND trans_files ${${_PLUGIN}_TRANSLATION_ADDFILES}) + acg_add_translation(Plugin-${plugin} ${${_PLUGIN}_TRANSLATION_LANGUAGES} ${trans_files}) + endif () + else () message (STATUS "[WARNING] One or more dependencies for plugin ${plugin} not found. Skipping plugin.") message (STATUS "Missing dependencies :${_${_PLUGIN}_MISSING_DEPS}")