summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2018-12-30 14:34:22 +0100
committerSlávek Banko <slavek.banko@axis.cz>2018-12-30 14:34:22 +0100
commit789ce7593273887580c4edcaefc2e6f9d20a9a44 (patch)
treeec604ac6e9fe33ac1020b0902109fdfee740b874 /src
parent11aab8f5619f0ee1c9aec39b66f11da724111cdd (diff)
downloadtellico-789ce7593273887580c4edcaefc2e6f9d20a9a44.tar.gz
tellico-789ce7593273887580c4edcaefc2e6f9d20a9a44.zip
Add CMakeL10n rules.
Update translation template. Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'src')
-rw-r--r--src/CMakeL10n.txt98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/CMakeL10n.txt b/src/CMakeL10n.txt
new file mode 100644
index 0000000..2abab87
--- /dev/null
+++ b/src/CMakeL10n.txt
@@ -0,0 +1,98 @@
+##### prepare strings from data files ###########
+
+message( STATUS "Prepare to extract strings from tellico data files..." )
+
+## core/tellico_config.kcfg
+tde_l10n_prepare_xml(
+ SOURCE "core/tellico_config.kcfg"
+ TAGS "default"
+ C_FORMAT
+)
+file( READ "${CMAKE_CURRENT_SOURCE_DIR}/core/tellico_config.kcfg.tde_l10n" _config_data )
+string( REGEX REPLACE "[^\n]" "" _config_len ${_config_data} )
+string( LENGTH "+${_config_len}" _config_len )
+set( _config_pos 0 )
+unset( _config_l10n )
+while( _config_pos LESS ${_config_len} )
+ # pick line
+ string( REGEX REPLACE "^([^\n]*)\n(.*)" "\\1" _config_line "${_config_data}" )
+ string( REGEX REPLACE "^([^\n]*)\n(.*)" "\\2" _config_data "${_config_data}" )
+ math( EXPR _config_pos "${_config_pos}+1" )
+
+ # clean default config value without "code"
+ if( "${_config_line}" MATCHES "i18n\\(\"i18n\\(" )
+ string( REGEX REPLACE
+ "i18n\\(\"i18n\\(\\\\\"(.*)\\\\\"\\)\"\\);"
+ "i18n(\"\\1\");"
+ _config_line "${_config_line}" )
+ else( )
+ set( _config_line "" )
+ endif( )
+
+ # write line
+ set( _config_l10n "${_config_l10n}${_config_line}\n" )
+endwhile( )
+file( WRITE "${CMAKE_CURRENT_SOURCE_DIR}/core/tellico_config.kcfg.tde_l10n" "${_config_l10n}" )
+
+## tips
+tde_l10n_preparetips( "../tellico.tips" )
+
+## xsl templates
+file( GLOB_RECURSE _xsl_files
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../xslt/*.xsl )
+unset( _xsl_list_l10n )
+set( _xsl_l10n "../xslt/.tde_l10n" )
+foreach( _xsl_file ${_xsl_files} )
+ if( "${_xsl_file}" MATCHES "/[^/]*-templates/" )
+ get_filename_component( _xsl_name "${_xsl_file}" NAME_WE )
+ string( REPLACE "_" " " _xsl_name "${_xsl_name}" )
+ set( _xsl_list_l10n
+ "${_xsl_list_l10n}i18n(\"${_xsl_name} XSL Template\", \"${_xsl_name}\");\n" )
+ endif( )
+ tde_l10n_prepare_xml( SOURCE ${_xsl_file} TAGS i18n )
+ list( APPEND _xsl_l10n "${_xsl_file}.tde_l10n" )
+endforeach( )
+file( WRITE "${CMAKE_CURRENT_SOURCE_DIR}/../xslt/.tde_l10n" "${_xsl_list_l10n}" )
+
+## z3950 servers
+file( READ "${CMAKE_CURRENT_SOURCE_DIR}/fetch/z3950-servers.cfg" _z3950_servers )
+string( REGEX REPLACE
+ "(^|\n)Name=([^\n]+)"
+ "\\1i18n(\"\\2\");"
+ _z3950_l10n "${_z3950_servers}"
+)
+file( WRITE "${CMAKE_CURRENT_SOURCE_DIR}/fetch/z3950-server.cfg.tde_l10n" "${_z3950_l10n}" )
+
+## scripts spec
+file( GLOB_RECURSE _scripts_files
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/fetch/scripts/*.spec )
+unset( _scripts_l10n )
+foreach( _script_file ${_scripts_files} )
+ file( READ "${CMAKE_CURRENT_SOURCE_DIR}/${_script_file}" _script_spec )
+ string( REGEX REPLACE
+ "(^|\n)Name=([^\n]+)"
+ "\\1i18n(\"\\2\");"
+ _script_l10n "${_script_spec}"
+ )
+ file( WRITE "${CMAKE_CURRENT_SOURCE_DIR}/${_script_file}.tde_l10n" "${_script_l10n}" )
+ list( APPEND _scripts_l10n "${_script_file}.tde_l10n" )
+endforeach( )
+
+
+##### create translation templates ##############
+
+tde_l10n_create_template(
+ CATALOG "tellico"
+ SOURCES
+ "."
+ "core/tellico_config.kcfg.tde_l10n"
+ "../tellico.tips.tde_l10n"
+ ${_xsl_l10n}
+ "fetch/z3950-server.cfg.tde_l10n"
+ ${_scripts_l10n}
+ EXCLUDES
+ "^core/tellico_config\\\\.kcfg\\$"
+ COMMENT "TRANSLATORS:"
+)