Update TDEL10n module

+ Input files with the extension ".tde_l10n" are considered
  as temporary modified source files.
+ Location information for such files in generated POT file
  will be modified to refer to the corresponding original
  files without the extension ".tde_l10n".
+ After the POT file is generated, these temporary modified
  source files will be automatically deleted.

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

@ -300,16 +300,16 @@ macro( tde_create_l10n_template )
# pick resource files *.kcfg, *.rc and *.ui
foreach( _src ${_files} )
if( ${_src} MATCHES "\\.(kcfg|rc|ui)(\\.cmake)?$" )
if( ${_src} MATCHES "\\.(kcfg|rc|ui)(\\.cmake)?(\\.tde_l10n)?$" )
list( APPEND _rcs ${_src} )
list( REMOVE_ITEM _files ${_src} )
endif( )
endforeach( )
# prepare extracted-rc.cpp
# prepare extracted-rc.tde_l10n
if( _rcs OR _attributes )
file( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/extracted-rc.cpp "" )
list( APPEND _files extracted-rc.cpp )
file( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/extracted-rc.tde_l10n "" )
list( APPEND _files extracted-rc.tde_l10n )
endif( )
# process resource files
@ -319,7 +319,7 @@ macro( tde_create_l10n_template )
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE _sources_rc
)
file( APPEND ${CMAKE_CURRENT_SOURCE_DIR}/extracted-rc.cpp ${_sources_rc} )
file( APPEND ${CMAKE_CURRENT_SOURCE_DIR}/extracted-rc.tde_l10n ${_sources_rc} )
endif( )
# extract attributes
@ -340,7 +340,7 @@ macro( tde_create_l10n_template )
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE _attrib_rc
)
file( APPEND ${CMAKE_CURRENT_SOURCE_DIR}/extracted-rc.cpp ${_attrib_rc} )
file( APPEND ${CMAKE_CURRENT_SOURCE_DIR}/extracted-rc.tde_l10n ${_attrib_rc} )
endif( )
endif( )
endforeach( )
@ -348,7 +348,7 @@ macro( tde_create_l10n_template )
# pick desktop files *.desktop and *.protocol
foreach( _src ${_files} )
if( ${_src} MATCHES "\\.(desktop|protocol)(\\.cmake)?$" )
if( ${_src} MATCHES "\\.(desktop|protocol)(\\.cmake)?(\\.tde_l10n)?$" )
list( APPEND _desktops ${_src} )
list( REMOVE_ITEM _files ${_src} )
endif( )
@ -414,7 +414,7 @@ macro( tde_create_l10n_template )
# update references for resources to original files and line numbers
if( _rcs OR _attributes )
file( STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/extracted-rc.cpp" _extractedRC )
file( STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/extracted-rc.tde_l10n" _extractedRC )
list( LENGTH _extractedRC _extractedRC_len )
set( _rcPos 0 )
while( _rcPos LESS ${_extractedRC_len} )
@ -424,12 +424,15 @@ macro( tde_create_l10n_template )
string( REGEX REPLACE "^//i18n: file (.*) line ([0-9]*)$" "\\1:\\2" _rcOrig ${_rcLine} )
endif( )
if( "${_rcLine}" MATCHES "^i18n\\(" AND _rcOrig )
string( REGEX REPLACE "(^|\n)(#:.*) extracted-rc.cpp:${_rcPos}( |\n)" "\\1\\2 ${_rcOrig}\\3" _pot ${_pot} )
string( REGEX REPLACE "(^|\n)(#:.*) extracted-rc.tde_l10n:${_rcPos}( |\n)" "\\1\\2 ${_rcOrig}\\3" _pot ${_pot} )
unset( _rcOrig )
endif( )
endwhile( )
endif( )
# update references for modified source files (".tde_l10n" extension)
string( REGEX REPLACE "\\.tde_l10n(:[0-9]+)" "\\1" _pot ${_pot} )
# save translation template
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_dest}${_catalog}.pot" )
file( READ "${CMAKE_CURRENT_SOURCE_DIR}/${_dest}${_catalog}.pot" _potOrig )
@ -447,8 +450,10 @@ macro( tde_create_l10n_template )
endif( _pot )
# cleanup
if( _rcs OR _attributes )
file( REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/extracted-rc.cpp )
endif( )
foreach( _file ${_files} ${_rsc} ${_desktops} )
if( "${_file}" MATCHES "\\.tde_l10n$" )
file( REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/${_file} )
endif( )
endforeach( )
endmacro( )

Loading…
Cancel
Save