summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2019-07-29 18:24:29 +0200
committerSlávek Banko <slavek.banko@axis.cz>2019-07-29 18:24:59 +0200
commitef69a23441c3b6c85b91609ea63ed799632ac8d3 (patch)
treea81c97df515b5241a2abeef0a9b081a6c0f70053
parent5480a1f3568edb96be8f2530f4fe2348979e0c28 (diff)
downloadtdelibs-ef69a23441c3b6c85b91609ea63ed799632ac8d3.tar.gz
tdelibs-ef69a23441c3b6c85b91609ea63ed799632ac8d3.zip
CMakeL10n: Extract strings from tdeabc/scripts/entrylist
instead of generating addressee source files. Signed-off-by: Slávek Banko <slavek.banko@axis.cz> (cherry picked from commit 298bd920d17320718c733030c02ad6bc8ed43c93)
-rw-r--r--CMakeL10n.txt62
1 files changed, 47 insertions, 15 deletions
diff --git a/CMakeL10n.txt b/CMakeL10n.txt
index 4194724ea..1606387a8 100644
--- a/CMakeL10n.txt
+++ b/CMakeL10n.txt
@@ -40,12 +40,52 @@ if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../dependencies/tqt3/src/xml/qxml.cpp )
endif( )
-##### generate tdeabc/addressee files ###########
-
-execute_process(
- COMMAND perl ./makeaddressee
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tdeabc/scripts
-)
+##### prepare tdeabc/addressee strings ##########
+
+# read file
+file( READ "${CMAKE_CURRENT_SOURCE_DIR}/tdeabc/scripts/entrylist" _addressee_data )
+string( REGEX REPLACE "[^\n]" "" _addressee_len ${_addressee_data} )
+string( LENGTH "+${_addressee_len}" _addressee_len )
+
+# process lines
+set( _addressee_pos 0 )
+unset( _addressee_l10n )
+while( _addressee_pos LESS ${_addressee_len} )
+ # pick line
+ string( REGEX REPLACE "^([^\n]*)\n(.*)" "\\1" _addressee_line "${_addressee_data}" )
+ string( REGEX REPLACE "^([^\n]*)\n(.*)" "\\2" _addressee_data "${_addressee_data}" )
+ math( EXPR _addressee_pos "${_addressee_pos}+1" )
+
+ if( "${_addressee_line}" MATCHES "^ *$" OR "${_addressee_line}" MATCHES "^ *#" )
+ set( _addressee_line "" )
+ else( )
+ string( REGEX REPLACE "^[^,]*,([^,]*),([^,]*),.*" "\\1" _addressee_field "${_addressee_line}" )
+ string( REGEX REPLACE "^[^,]*,([^,]*),([^,]*),.*" "\\2" _addressee_comment "${_addressee_line}" )
+ if( NOT "${_addressee_field}" STREQUAL "" )
+ string( REGEX REPLACE "[_ ]+" ";" _addressee_field ${_addressee_field} )
+ unset( _addressee_field_name )
+ foreach( _addressee_field_part ${_addressee_field} )
+ string( SUBSTRING ${_addressee_field_part} 0 1 _addressee_field_first )
+ string( SUBSTRING ${_addressee_field_part} 1 -1 _addressee_field_rest )
+ string( TOUPPER ${_addressee_field_first} _addressee_field_first )
+ set( _addressee_field_name "${_addressee_field_name}${_addressee_field_first}${_addressee_field_rest} " )
+ endforeach( )
+ string( STRIP ${_addressee_field_name} _addressee_field_name )
+
+ if( NOT "${_addressee_comment}" STREQUAL "" )
+ set( _addressee_line "i18n(\"${_addressee_comment}\", \"${_addressee_field_name}\");" )
+ else( )
+ set( _addressee_line "i18n(\"${_addressee_field_name}\");" )
+ endif( )
+ else( )
+ set( _addressee_line "" )
+ endif( )
+ endif( )
+ set( _addressee_l10n "${_addressee_l10n}${_addressee_line}\n" )
+endwhile( )
+
+# write file
+file( WRITE "${CMAKE_CURRENT_SOURCE_DIR}/tdeabc/scripts/entrylist.tde_l10n" "${_addressee_l10n}" )
##### create translation templates ##############
@@ -62,6 +102,7 @@ tde_l10n_create_template(
CATALOG "tdelibs"
SOURCES
"."
+ "tdeabc/scripts/entrylist.tde_l10n"
"tdecore/tde-config.cpp.cmake"
"../dependencies/tqt3/src"
"../dependencies/tqt3/src/xml/qxml.cpp.tde_l10n"
@@ -91,15 +132,6 @@ tde_l10n_create_template(
)
-##### clenaup tdeabc/addressee files ############
-
-file( REMOVE
- ${CMAKE_CURRENT_SOURCE_DIR}/tdeabc/addressee.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/tdeabc/addressee.h
- ${CMAKE_CURRENT_SOURCE_DIR}/tdeabc/field.cpp
-)
-
-
##### create translation templates ##############
tde_l10n_auto_add_subdirectories( )