##### prepare list of schemas ###################

file( GLOB _konsole_schema_files
  RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}/../other/*.[Ss]chema
)
unset( _konsole_schemas )
list( SORT _konsole_schema_files )
foreach( _konsole_schema_file ${_konsole_schema_files} )
  file( READ ${CMAKE_CURRENT_SOURCE_DIR}/${_konsole_schema_file} _konsole_schema_data )
  string( REGEX REPLACE "(^|\n)([^\n]+)" "\\1:\\2" _konsole_schema_data "${_konsole_schema_data}" )
  string( REGEX REPLACE "(^|\n):title +([^\n]*)" "\\1i18n(\"\\2\");" _konsole_schema_data "${_konsole_schema_data}" )
  string( REGEX REPLACE "(^|\n):[^\n]*" "\\1" _konsole_schema_data "${_konsole_schema_data}" )
  file( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/${_konsole_schema_file}.tde_l10n "${_konsole_schema_data}" )
  list( APPEND _konsole_schemas ${_konsole_schema_file}.tde_l10n )
endforeach( )

file( GLOB _konsole_keytab_files
  RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}/../other/*.[Kk]eytab
)
unset( _konsole_keytabs )
list( SORT _konsole_keytab_files )
foreach( _konsole_keytab_file ${_konsole_keytab_files} )
  file( READ ${CMAKE_CURRENT_SOURCE_DIR}/${_konsole_keytab_file} _konsole_keytab_data )
  string( REGEX REPLACE "(^|\n)([^\n]+)" "\\1:\\2" _konsole_keytab_data "${_konsole_keytab_data}" )
  string( REGEX REPLACE "(^|\n):keyboard +([^\n]*)" "\\1i18n(\\2);" _konsole_keytab_data "${_konsole_keytab_data}" )
  string( REGEX REPLACE "(^|\n):[^\n]*" "\\1" _konsole_keytab_data "${_konsole_keytab_data}" )
  file( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/${_konsole_keytab_file}.tde_l10n "${_konsole_keytab_data}" )
  list( APPEND _konsole_keytabs ${_konsole_keytab_file}.tde_l10n )
endforeach( )


##### create translation templates ##############

tde_l10n_create_template(
    CATALOG "konsole"
    SOURCES "." ${_konsole_schemas} ${_konsole_keytabs} "../tips"
)
