Commit 65405a95 authored by Jan Möbius's avatar Jan Möbius

Dennis: Translations

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6715 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 69be7349
......@@ -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
......
......@@ -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
......
......@@ -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 (
......
......@@ -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}")
......
......@@ -460,3 +460,55 @@ function (acg_add_library _target _libtype)
endif ()
endif ()
endfunction ()
#generates qt translations
function (acg_add_translations _target _languages _sources)
string (TOUPPER ${_target} _TARGET)
# generate/use translation files
# run with UPDATE_TRANSLATIONS set to on to build qm files
option (UPDATE_TRANSLATIONS_${_TARGET} "Update source translation *.ts files (WARNING: make clean will delete the source .ts files! Danger!)")
set (_new_ts_files)
set (_ts_files)
foreach (lang ${_languages})
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/translations/${_target}_${lang}.ts" OR UPDATE_TRANSLATIONS_${_TARGET})
list (APPEND _new_ts_files "${_target}_${lang}.ts")
else ()
list (APPEND _ts_files "${_target}_${lang}.ts")
endif ()
endforeach ()
set (_qm_files)
if (${_new_ts_files})
qt4_create_translation(_qm_files ${_sources} ${_new_ts_files})
endif ()
if (${_ts_files})
qt4_add_translation(_qm_files2 ${_ts_files})
list (APPEND _qm_files ${_qm_files2})
endif ()
# create a target for the translation files ( and object files )
# Use this target, to update only the translations
add_custom_target (translations_target_${_target} DEPENDS ${_qm_files})
# Build translations with the application
add_dependencies(${_target} translations_target_${_target} )
if (NOT EXISTS ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Translations)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Translations )
endif ()
add_custom_command (TARGET translations_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/ )
if (NOT ACG_PROJECT_MACOS_BUNDLE OR NOT APPLE)
install (FILES ${_qm_files} DESTINATION "${CMAKE_INSTALL_PREFIX}/Translations")
endif ()
endfunction ()
Markdown is supported
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