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>
(cherry picked from commit 510c8ba0d9)
v3.5.13-sru
Slávek Banko 3 years ago
parent f723653f70
commit 0ac3858498
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -1636,6 +1636,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]
@ -1653,6 +1654,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} )
@ -1670,6 +1672,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 )
@ -1885,17 +1894,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( )
@ -1909,6 +1929,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