summaryrefslogtreecommitdiffstats
path: root/CMakeL10n.txt
blob: c7670275d898f307f71971e5e2071d7cc92f4f11 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#################################################
#
#  (C) 2018 Slávek Banko
#  slavek.banko (AT) axis.cz
#
#  Improvements and feedback are welcome
#
#  This file is released under GPL >= 2
#
#################################################

cmake_minimum_required( VERSION 2.8 )


##### include our cmake modules #################

set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" )
include( TDEL10n )


##### set directory for POT files ###############

set( POT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../tde-i18n/template/messages/tdelibs" )


##### verify tqt3 sources #######################

if( NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../dependencies/tqt3/src )
  tde_message_fatal( "TQt3 source code is required but not found" )
endif( )


##### prepare tqt3/src/xml/qxml.cpp #############

if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../dependencies/tqt3/src/xml/qxml.cpp )
  # hide "#define" to allow strings to be extracted using xgettext
  file( READ ${CMAKE_CURRENT_SOURCE_DIR}/../dependencies/tqt3/src/xml/qxml.cpp _tqt_qxml )
  string( REGEX REPLACE "\n(#define[^\n]*)(QT_TRANSLATE_NOOP)" "\n/*\\1*/\\2" _tqt_qxml ${_tqt_qxml} )
  file( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/../dependencies/tqt3/src/xml/qxml.cpp.tde_l10n "${_tqt_qxml}" )
endif( )


##### prepare tderandr/libtderandr.h #############

# hide "#define" to allow strings to be extracted using xgettext
file( READ ${CMAKE_CURRENT_SOURCE_DIR}/tderandr/libtderandr.h _tderandr_h )
string( REGEX REPLACE "\n(#define[^\n]*)(I18N_NOOP)" "\n/*\\1*/\\2" _tderandr_h ${_tderandr_h} )
file( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/tderandr/libtderandr.h.tde_l10n "${_tderandr_h}" )


##### 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 ##############

tde_l10n_create_template(
    CATALOG "tde"
    SOURCES "common_texts.cpp"
    EXCLUDES "_translatorinfo"
    X-POT -
    DESTINATION "."
)

tde_l10n_create_template(
  CATALOG "tdelibs"
  SOURCES
    "."
    "tdeabc/scripts/entrylist.tde_l10n"
    "tdecore/tde-config.cpp.cmake"
    "tderandr/libtderandr.h.tde_l10n"
    "../dependencies/tqt3/src"
    "../dependencies/tqt3/src/xml/qxml.cpp.tde_l10n"
  EXCLUDES
    "/test/" "/tests/"
    "^arts/kde/mcop-dcop/"
    "^arts/knotify/"
    "^interfaces/tdemediaplayer/tdefileaudiopreview/"
    "^kate/"
    "^kdoctools/"
    "^libtdescreensaver/"
    "^tdeabc/formats/"
    "^tdeabc/plugins/"
    "^tdecmshell/"
    "^tdecore/tdeconfig_compiler/example/"
    "^tdeio/"
    "^tdeioslave/"
    "^tdeprint/"
    "^tderandr/libtderandr.h$"
    "^tdestyles/.*/config/"
    "^tdeui/colors/"
    "/dependencies/tqt3/src/xml/qxml.cpp$"
  KEYWORDS
    tr tr:1,2
    translate translate:1,2
    QT_TRANSLATE_NOOP QT_TRANSLATE_NOOP:1,2
  X-POT "-"
)


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

tde_l10n_auto_add_subdirectories( )