Add CMakeL10n rules to update all_languages.desktop

according to the entry.desktop files from tde-i18n.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit cb418ed3fd)
r14.0.x
Slávek Banko 4 years ago
parent b58ef27fa5
commit dc9adc1b0f
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -1,3 +1,71 @@
##### update all_languages.desktop ##############
message( STATUS "Update all_languages.desktop according to the entry.desktop files from tde-i18n" )
# read the current list of language codes and names
unset( _languages_code )
unset( _languages_name )
file( READ ${CMAKE_CURRENT_SOURCE_DIR}/all_languages.desktop _langs_current )
string( REGEX REPLACE "[^\n]" "" _langs_current_len "${_langs_current}" )
string( LENGTH "+${_langs_current_len}" _langs_current_len )
set( _langs_current_pos 0 )
while( _langs_current_pos LESS ${_langs_current_len} )
string( REGEX REPLACE "^([^\n]*)\n(.*)" "\\1" _lang_row "${_langs_current}" )
string( REGEX REPLACE "^([^\n]*)\n(.*)" "\\2" _langs_current "${_langs_current}" )
math( EXPR _langs_current_pos "${_langs_current_pos}+1" )
if( "${_lang_row}" MATCHES "^\\[.*\\]$" )
string( REGEX REPLACE "^\\[(.*)\\]$" "\\1" _lang_code ${_lang_row} )
endif()
if( (NOT "${_lang_code}" STREQUAL "") AND
("${_lang_row}" MATCHES "^ *Name *=") )
string( REGEX REPLACE "^ *Name *= *" "" _lang_name "${_lang_row}" )
list( APPEND _languages_code ${_lang_code} )
list( APPEND _languages_name ${_lang_name} )
unset( _lang_code )
endif()
endwhile()
# merge with languages from tde-i18n entry.desktop files
file( GLOB _languages_dirs
RELATIVE ${CMAKE_SOURCE_DIR}/../tde-i18n
${CMAKE_SOURCE_DIR}/../tde-i18n/tde-i18n-*
)
foreach( _lang_dir IN LISTS _languages_dirs )
if( EXISTS ${CMAKE_SOURCE_DIR}/../tde-i18n/${_lang_dir}/messages/entry.desktop )
string( REPLACE "tde-i18n-" "" _lang_code ${_lang_dir} )
file( READ ${CMAKE_SOURCE_DIR}/../tde-i18n/${_lang_dir}/messages/entry.desktop _lang_name )
string( REGEX REPLACE "(^|.*\n) *Name *= *([^\n]*).*" "\\2" _lang_name "${_lang_name}" )
if( NOT "${_lang_name}" STREQUAL "" )
list( FIND _languages_code "${_lang_code}" _lang_index )
if( "${_lang_index}" GREATER -1 )
list( REMOVE_AT _languages_code ${_lang_index} )
list( REMOVE_AT _languages_name ${_lang_index} )
endif()
list( APPEND _languages_code ${_lang_code} )
list( APPEND _languages_name ${_lang_name} )
endif()
endif()
endforeach()
# create new all_languages.desktop
unset( _languages )
foreach( _lang_code IN LISTS _languages_code )
list( FIND _languages_code "${_lang_code}" _lang_index )
list( GET _languages_name ${_lang_index} _lang_name )
list( APPEND _languages "${_lang_code}: ${_lang_name}" )
endforeach()
if( _languages )
unset( _all_languages )
list( SORT _languages )
foreach( _lang IN LISTS _languages )
string( REGEX REPLACE "^([^:]*): (.*)" "\\1" _lang_code ${_lang} )
string( REGEX REPLACE "^([^:]*): (.*)" "\\2" _lang_name ${_lang} )
set( _all_languages "${_all_languages}[${_lang_code}]\nName=${_lang_name}\n" )
endforeach()
file( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/all_languages.desktop "${_all_languages}" )
endif()
##### create translation templates ############## ##### create translation templates ##############
tde_l10n_create_template( tde_l10n_create_template(

Loading…
Cancel
Save