summaryrefslogtreecommitdiffstats
path: root/src/CMakeL10n.txt
blob: 050471a00a1dc14b5adf819d77a5b3458759f024 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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 "messages/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:"
)