[go: up one dir, main page]

File: i18n.cook

package info (click to toggle)
cook 2.29-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 8,656 kB
  • ctags: 4,083
  • sloc: ansic: 47,636; sh: 14,376; makefile: 4,656; yacc: 3,166; perl: 224; awk: 219
file content (257 lines) | stat: -rw-r--r-- 7,757 bytes parent folder | download
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/*
 *      cook - file construction tool
 *      Copyright (C) 2002, 2007 Peter Miller;
 *      All rights reserved.
 *
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
 *
 * MANIFEST: etc/i18n.cook
 */

all,I =
        [fromto %0%.y %0%.gen.c,I [match_mask %0%.y [source_files]]]
        [fromto %0%.c %0%.c,I [match_mask %0%.c [source_files]]]
        ;

common,I =
        [fromto
                common/%0%.c
                common/%0%.c,I
                [match_mask common/%0%.c [source_files]]
        ]
        [fromto
                common/%0%.y
                common/%0%.gen.c,I
                [match_mask common/%0%.y [source_files]]
        ];

/*
 * Translate the locatization files into their binary form.  This will
 * be different for each architecture and operating system (in theory,
 * if not in practice).
 */

internationalization:
        lib/common.ok
        [fromto lib/%0%.po [arch]/lib/%0%.mo
                [match_mask lib/%0%.po [source_files]]
        ]
        [fromto lib/%0%.po lib/%0%.merge
                [match_mask lib/%0%.po [source_files]]
        ]
        LICENSE
        ;

lib/common.ok: lib/common.pot etc/zer-len-msg.sh
{
        sh [resolve etc/zer-len-msg.sh lib/common.pot];
        touch [target];
}

msgcomm = msgcomm;

lib/common.pot: [prepost "lib/" ".po" [commands]]
{
        [msgcomm]
                --force-po
                --omit-header
                --sort-output
                --add-location
                --indent
                --width\=75
                -o [target]
                [prepost "--dir=" "" [search_list]]
                [need];
}


msgmerge = msgmerge;

lib/%0%.merge: lib/%0%.po lib/%.po
{
        [msgmerge]
                --indent
                --sort-output
                --width\=75
                -v -v
                --no-location
                --force-po
                -o [target]
                [resolve lib/%0%.po lib/%.po]
                ;

        /*
         * There should be no differences.
         * If there are, this next command will show them.
         */
        diff -b -u [resolve lib/%0%.po] [target];

        /*
         * we only need the timestamp
         */
        > [target];
}


[arch]/lib/%0%.mo: lib/%0%.po: lib/%0common.po
        etc/msgfmt.sh
        set ['if' [not [defined baseline]] 'then' shallow]
{
        /*
         * This only works for GNU gettext (and Solaris).
         * The SunOS msgfmt program does not grok the -o option.
         */
        sh [resolve etc/msgfmt.sh]
                --msgfmt\=[msgfmt]
                --msgcat\=[msgcat]
                --output\=[target]
                [resolve lib/%0%.po lib/%0common.po]
                ;
}


xgettext = xgettext;

/*
 * These files act as a "header files" to check the lib/%0%.po files
 * against.  There should not be any extras or omitions.
 */

lib/common.po: [all,I] [prepost "lib/en/LC_MESSAGES/" ".po" [commands]]
{
        /*
         * The author only speaks English, so the master translation is
         * "en", hence lib/en/LC_MESSAGES/....po are the files intended.
         */
        [xgettext]
                --sort-output
                --indent
                --omit-header
                --add-location
                --force-po
                --width\=75
                -o [target]
                [prepost "--dir=" "" [search_list]]
                [prepost "--exclude-file=lib/en/LC_MESSAGES/" ".po" [commands]]
                --language\=PO
                [all,I];
}

lib/%.po: [%,I]: lib/en/LC_MESSAGES/common.po
{
        /*
         * The author only speaks English, so the master translation is
         * "en", hence lib/en/LC_MESSAGES/common.po is the file
         * intended.
         */
        [xgettext]
                --sort-output
                --indent
                --omit-header
                --add-location
                --force-po
                -o [target]
                [prepost "--dir=" "" [search_list]]
                --exclude-file\=lib/en/LC_MESSAGES/common.po
                --language\=PO
                [%,I];
}

%0%.c,I: %0%.c
        set no-cascade
{
        [xgettext]
                --sort-output
                --indent
                --omit-header
                --force-po
                --add-location
                -o [target]
                --msgstr-prefix\=
                --msgstr-suffix\=
                --keyword\=i18n
                --keyword\=error_intl
                --keyword\=fatal_intl
                --keyword\=verbose_intl
                --keyword\=subst_intl
                --keyword\=fngrprnt_error
                --keyword\=lex_error
                --keyword\=lex_warning
                [prepost "--dir=" "" [search_list]]
                %0%.c;
}


/*
 * This next file is for the benefit of the Translation Project's
 * email robot.  (Yes, that's right, a bloody robot.)
 *
 * See http://www.iro.umontreal.ca/contrib/po/HTML/maintainers.html
 * for more information.
 *
 * I particularly dislike this approach, because it is incredibly
 * short sighted.  This approach fails to take into account that
 * you may want to have translations of manual pages and other
 * documentation, AS WELL AS translations of error messages.
 *
 * Would it make sense to ask authors to catenate all of
 * ther man pages together, and have a po/PACKAGE.man file?
 * No, of course not.  Would it make sense to ask authors to
 * catenate all of their other documentation together, and
 * have a po/PACKAGE.latex file?  No, of course not.  Well then,
 * why on Earth does it make sense to catenate together all of
 * the messages into a po/PACKAGE.pot file?  Betch.
 *
 * And then, to add insult to injury, it wastes space in the tarball.
 *
 * My project uses a directory tree
 *      lib/
 *          <LL>/
 *              LC_MESSAGES/
 *                  all of the various .po files go here
 *              man<N>/
 *                  all of the man<N> pages go here
 *              user-guide/
 *                  all of the files which make the
 *                  user guide go here.
 *              <other-docs>/
 *                  and so on...
 *
 * As you can see, this can accomodate translated .po files,
 * AND ALSO any other documentation, once it is translated.
 */

po/[project_short].pot: [match_mask lib/en/LC_MESSAGES/%.po [source_files]]
{
        msgcat
                --use-first
                --indent
                --sort-output
                --width\=75
                -o [target]
                [resolve
                    /*
                     * Put common.po at the start, it has an informative
                     * comment at the beginning (which gets bound to
                     * "", and is subject a the --use-first clause).
                     */
                    lib/en/LC_MESSAGES/common.po
                    [stringset
                        [need]
                    -
                        lib/en/LC_MESSAGES/common.po
                    ]
                ];
}