summaryrefslogtreecommitdiff
path: root/autoopts/tpl/usage-txt.tpl
blob: fad1a0d84a8a02eddb502154ff8f5b3497e76f50 (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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
[= AutoGen5 Template

  h  pot

(define time-stamp "2012-02-18 10:10:47")

##  This file is part of AutoOpts, a companion to AutoGen.
##  AutoOpts is free software.
##  AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
##
##  AutoOpts is available under any one of two licenses.  The license
##  in use must be one of these two and the choice is under the control
##  of the user of the license.
##
##   The GNU Lesser General Public License, version 3 or later
##      See the files "COPYING.lgplv3" and "COPYING.gplv3"
##
##   The Modified Berkeley Software Distribution License
##      See the file "COPYING.mbsd"
##
##  These files have the following md5sums:
##
##  43b91e8ca915626ed3818ffb1b71248b COPYING.gplv3
##  06a1a2e4760c90ea5e1dad8dfaac4d39 COPYING.lgplv3
##  66a5cedaf62c4b2637025f049f9b826f COPYING.mbsd

=][=  CASE (suffix) =][=

==  h               =][=

(define ref-list "")
(define cch-ct   0)
(dne " *  " "/*  ") =]
 *
 *  This file handles all the bookkeeping required for tracking all the little
 *  tiny strings used by the AutoOpts library.  There are [= (count "utxt") =]
 *  of them.  This is not versioned because it is entirely internal to the
 *  library and accessed by client code only in a very well-controlled way:
 *  they may substitute translated strings using a procedure that steps through
 *  all the string pointers.
 *
[= (license-full "lgpl" "AutoOpts" " *  " "Bruce Korb" (shell "date +1992-%Y"))
 =]
 */
[=
(make-header-guard "autoopts")
=]

#undef  cch_t
#define cch_t char const

/*
 *  One structure to hold all the pointers to all the stringlets.
 */
typedef struct {
  int       field_ct;[=
FOR utxt        =][=
  (if (exist? "ut-type")
      (emit (sprintf "\n  %-9s utpz_%s;"
                     (string-append (get "ut-type") "*")
                     (get "ut-name")  ))
      (set! cch-ct (+ cch-ct 1))  ) =][=

ENDFOR  utxt    =]
  cch_t*    apz_str[ [= (. cch-ct) =] ];
} usage_text_t;

/*
 *  Declare the global structure with all the pointers to translated
 *  strings.  This is then used by the usage generation procedure.
 */
extern usage_text_t option_usage_text;

#if defined(AUTOOPTS_INTERNAL) /* DEFINE ALL THE STRINGS = = = = = */
/*
 *  Provide a mapping from a short name to fields in this structure.
 */[=

(string-table-new  "usage_txt")
(define str-ix     0)
(define const-list "")
(define typed-list "")
(set! cch-ct 0)    =][=

FOR utxt        =]
#define z[= (sprintf "%-20s" (get "ut-name"))
        =] (option_usage_text.[=

  IF (exist? "ut-type") =]utpz_[= ut-name =][=
     (set! typed-list (string-append typed-list "\n" (get "ut-name"))) =][=
  ELSE
    =][=
    (ag-fprintf 0 "apz_str[%3d]" cch-ct)
    (set! cch-ct (+ 1 cch-ct))
    =][=
  ENDIF                 =])[=
ENDFOR =]

  /*
   *  First, set up the strings.  Some of these are writable.  These are all in
   *  English.  This gets compiled into libopts and is distributed here so that
   *  xgettext (or equivalents) can extract these strings for translation.
   */
[=
FOR utxt  =][=
  (if (exist? "ut-type")
      (sprintf "\n  static %-7s eng_z%s[] = %s;"
              (get "ut-type") (get "ut-name") (kr-string (get "ut-text"))
      )

      (begin
        (set! str-ix (string-table-add "usage_txt" (get "ut-text")))
        (set! const-list (string-append const-list
                         (sprintf "usage_txt +%4d\n" str-ix)  ))
  )   )
  =][=
ENDFOR  utxt        =][=

(emit-string-table "usage_txt")

=]

  /*
   *  Now, define (and initialize) the structure that contains
   *  the pointers to all these strings.
   *  Aren't you glad you don't maintain this by hand?
   */
  usage_text_t option_usage_text = {
    [= (count "utxt") =],
[= (shell (string-append
  "CLexe=${AGexe%/agen5/*}/columns/columns
  test -x \"${CLexe}\" || {
    CLexe=${AGexe%/autogen}/columns
    test -x \"${CLexe}\" || die 'columns program is not findable'
  }
  ${CLexe} -W84 -I4 --spread=1 -f'eng_z%s,' <<_EOF_" typed-list
  "\n_EOF_
  echo '    {'
  ${CLexe} -W84 -I6 --spread=1 -S, <<_EOF_\n" const-list
  "_EOF_" )) =]
    }
  };

#endif /* DO_TRANSLATIONS */
#endif /* [= (. header-guard) =] */
[=


==  pot


\=]
# Automated Option parsing usage text.
# copyright (c) [=`date +1999-%Y`=] by Bruce Korb - all rights reserved
# This file is distributed under the same license as the AutoOpts package.
# Bruce Korb <bkorb@gnu.org> [=`date +%Y`=]
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: autogen [=`echo ${AG_VERSION}`=]\n"
"Report-Msgid-Bugs-To: autogen-users@lists.sourceforge.net\n"
"POT-Creation-Date: [=`date '+%Y-%m-%d %H:%M%z'`=]\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
[=

FOR utxt
  =][=
  (set! ref-list (shellf
     "list=`grep -n -w z%s *.c [agpo]*.h tpl/opt*.t* | \\
         sed -n 's/\\([^:]*:[^:]*\\):.*/\\1/p'`
     echo ${list}" (get "ut-name")))

  (if (< (string-length ref-list) 2)
      (error (sprintf "No references to z%s string" (get "ut-name")))  )

  (sprintf "\n#: %s\nmsgid %s\n" ref-list (c-string (get "ut-text")))

  =][=
ENDFOR utxt

=]
[=

ESAC

# Local Variables:
# Mode: text
# time-stamp-format: "\"%:y-%02m-%02d %02H:%02M:%02S\""
# time-stamp-pattern: "(define time-stamp "
# time-stamp-end: ")"
# End:

\=]