summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2021-07-06 12:30:44 +0200
committerSlávek Banko <slavek.banko@axis.cz>2021-07-06 13:16:33 +0200
commit510c8ba0d9ec00152d6d783eefb8965363a6c441 (patch)
tree52275dfd6e0818d7a99ab491cc4b938c6411ff78
parent5bf1d5e81f7223919f33921ecfdf86576c0d5324 (diff)
downloadtde-cmake-510c8ba0d9ec00152d6d783eefb8965363a6c441.tar.gz
tde-cmake-510c8ba0d9ec00152d6d783eefb8965363a6c441.zip
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>
-rw-r--r--modules/TDEMacros.cmake37
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( )