diff options
-rw-r--r-- | modules/TDEMacros.cmake | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake index b1d7aaf..28e0558 100644 --- a/modules/TDEMacros.cmake +++ b/modules/TDEMacros.cmake @@ -1823,6 +1823,7 @@ endmacro( ) ##### tde_create_translated_desktop( ##### [SOURCE] file_name ##### [KEYWORDS keyword [keyword]] +##### [FORMAT (desktop|xml)] ##### [PO_DIR po_directory] ##### [DESTINATION directory] ##### [OUTPUT_NAME file_name] @@ -1840,6 +1841,7 @@ macro( tde_create_translated_desktop ) set( _keywords_desktop_default "Name" "GenericName" "Comment" "Keywords" "Description" "ExtraNames" "X-TDE-Submenu" ) + set( _format "desktop" ) foreach( _arg ${ARGN} ) @@ -1857,6 +1859,13 @@ macro( tde_create_translated_desktop ) set( _directive 1 ) endif( ) + # found directive "FORMAT" + if( "+${_arg}" STREQUAL "+FORMAT" ) + unset( _format ) + set( _var _format ) + set( _directive 1 ) + endif( ) + # found directive "PO_DIR" if( "+${_arg}" STREQUAL "+PO_DIR" ) unset( _arg_po_dir ) @@ -2072,17 +2081,28 @@ macro( tde_create_translated_desktop ) string( REPLACE ";" "|" _keywords_match "(${_keywords_desktop})" ) # merge translations command - add_custom_command( - OUTPUT ${_basename}${_binsuffix} - COMMAND ${PERL_EXECUTABLE} -p -e "'s/^${_keywords_match}[ ]*=[ ]*/_\\1=/'" < ${_src} > ${_basename}.in - COMMAND ${PERL_EXECUTABLE} ${INTLTOOL_MERGE_EXECUTABLE} -q -d ${_po_dir} ${_basename}.in ${_basename}${_binsuffix} - DEPENDS ${_src} - COMMENT "Merging translations into ${_sourcename}" - ) + if( _format STREQUAL "desktop" ) + add_custom_command( + OUTPUT ${_basename}${_binsuffix} + COMMAND ${PERL_EXECUTABLE} -p -e "'s/^${_keywords_match}[ ]*=[ ]*/_\\1=/'" < ${_src} > ${_basename}.in + COMMAND ${PERL_EXECUTABLE} ${INTLTOOL_MERGE_EXECUTABLE} -q -d ${_po_dir} ${_basename}.in ${_basename}${_binsuffix} + DEPENDS ${_src} + COMMENT "Merging translations into ${_sourcename}" + ) + elseif( _format STREQUAL "xml" ) + add_custom_command( + OUTPUT ${_basename}${_binsuffix} + COMMAND ${PERL_EXECUTABLE} -p -e "'s/(<\\/?)${_keywords_match}([ >])/\\1_\\2\\3/g'" < ${_src} > ${_basename}.in + COMMAND ${PERL_EXECUTABLE} ${INTLTOOL_MERGE_EXECUTABLE} -q -x ${_po_dir} ${_basename}.in ${_basename}${_binsuffix} + DEPENDS ${_src} + COMMENT "Merging translations into ${_sourcename}" + ) + else() + tde_message_fatal( "Unknown file format for merging translations." ) + endif() endif( ) - # merge translations target else( ) @@ -2096,6 +2116,7 @@ macro( tde_create_translated_desktop ) endif( ) + # merge translations target add_custom_target( "${_target}" ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_basename}${_binsuffix} ) endif( ) |