tde_create_translated_desktop: Add the ability to merge translations into files in XML format.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/77/head
Slávek Banko 3 years ago
parent 5bf1d5e81f
commit 510c8ba0d9
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -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,6 +2081,7 @@ macro( tde_create_translated_desktop )
string( REPLACE ";" "|" _keywords_match "(${_keywords_desktop})" )
# merge translations command
if( _format STREQUAL "desktop" )
add_custom_command(
OUTPUT ${_basename}${_binsuffix}
COMMAND ${PERL_EXECUTABLE} -p -e "'s/^${_keywords_match}[ ]*=[ ]*/_\\1=/'" < ${_src} > ${_basename}.in
@ -2079,10 +2089,20 @@ macro( tde_create_translated_desktop )
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( )

Loading…
Cancel
Save