• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/ap/gpl/timemachine/gettext-0.17/gettext-tools/tests/
1#!/bin/sh
2
3# Test of Perl support.
4
5tmpfiles=""
6trap 'rm -fr $tmpfiles' 1 2 3 15
7
8tmpfiles="$tmpfiles xg-pl-1.pl"
9cat <<\EOF > xg-pl-1.pl
10use Locale::Messages qw (textdomain bindtextdomain gettext ngettext dngettext);
11
12textdomain "prog";
13bindtextdomain "prog", "./";
14
15s/foo/
16          # stress test for string extraction /xe;
17
18print _"'Your command, please?', asked the waiter.";
19
20printf ngettext ("a piece of cake", "%d pieces of cake", $n), $n;
21
22printf _"%s is replaced by %s.", "FF", "EUR";
23
24# Should be found.
25printf dngettext prog => ("one file deleted", "%d files deleted"), $n, $n;
26
27# Should not be found.
28printf dngettext ("prog"), ("one file created", "%d files created"), $n, $n;
29
30printf dngettext "prog", <<PERL, <<PERL;
31Singular
32PERL
33Plural
34PERL
35
36print <<PERL
37tied hash $__{   Bareword
38}
39tied hash $__->{"quoted string"}
40tied hash $__->{  "weird
41formatting"}
42PERL
43
44print $__  # Welcome
45   ->   # to the
46 { # Republic of
47 'Welcome to the Republic of Perl!' # 
48# Perl!
49}; 
50
51$! ? ?$__{"pattern match"}? : s  # This is no delimiter.
52{$__{substitution}}<$__-\>{"find me"}>;
53
54# No interpolation!
55m'$__{secret}';
56
57# Multiple here documents invoked from the same line.
58print gettext <<PERL; print gettext <<PERL;
59First here document.
60PERL
61Second here document.
62PERL
63
64# These are not invalid interpolations, because the dollar is backslashed.
65printf "%s\n", gettext "abc\$def";
66printf "%s\n", gettext "abc\\\$def";
67
68# These are not interpolations.
69printf "%s\n", gettext 'abc$defg';
70printf "%s\n", gettext 'abc\$defg';
71printf "%s\n", gettext 'abc\\$defg';
72printf "%s\n", gettext 'abc\\\$defg';
73
74# Two consecutive backslashes count as one inside single-quote strings.
75printf "%s\n", gettext 'ecs\tasy';
76printf "%s\n", gettext 'ecs\\tasy';
77printf "%s\n", gettext 'ecs\\\tasy';
78printf "%s\n", gettext 'ecs\\\\tasy';
79printf "%s\n", gettext 'ecs\\\\\tasy';
80printf "%s\n", gettext q(ecs\tasy);
81printf "%s\n", gettext q(ecs\\tasy);
82printf "%s\n", gettext q(ecs\\\tasy);
83printf "%s\n", gettext q(ecs\\\\tasy);
84printf "%s\n", gettext q(ecs\\\\\tasy);
85
86# Similarly, inside double-quote strings, two consecutive backslashes count
87# as one, but the last backslash of a sequence is combined with the following
88# character if possible.
89printf "%s\n", gettext "ecs\tasy";
90printf "%s\n", gettext "ecs\\tasy";
91printf "%s\n", gettext "ecs\\\tasy";
92printf "%s\n", gettext "ecs\\\\tasy";
93printf "%s\n", gettext "ecs\\\\\tasy";
94printf "%s\n", gettext qq(ecs\tasy);
95printf "%s\n", gettext qq(ecs\\tasy);
96printf "%s\n", gettext qq(ecs\\\tasy);
97printf "%s\n", gettext qq(ecs\\\\tasy);
98printf "%s\n", gettext qq(ecs\\\\\tasy);
99printf "%s\n", gettext "mari\huana";
100printf "%s\n", gettext "mari\\huana";
101printf "%s\n", gettext "mari\\\huana";
102printf "%s\n", gettext "mari\\\\huana";
103printf "%s\n", gettext "mari\\\\\huana";
104printf "%s\n", gettext qq(mari\huana);
105printf "%s\n", gettext qq(mari\\huana);
106printf "%s\n", gettext qq(mari\\\huana);
107printf "%s\n", gettext qq(mari\\\\huana);
108printf "%s\n", gettext qq(mari\\\\\huana);
109
110# Recognition of format strings.
111gettext "This is {only} a brace formatstring.";
112gettext "This is %s {mixed}.";
113gettext "This is only %c.";
114gettext "This is nothing at all.";
115gettext "And this is %l also no format at all.";
116
117# xgettext: no-perl-format, perl-brace-format
118gettext "The function '{func}' expects '%c' here.";
119
120# This is a contradictory case: The same string three times,
121# with different xgettext comments.
122# xgettext: perl-brace-format, no-perl-format
123gettext "Left as an %exercise to {maintainer}.";
124# xgettext: no-perl-brace-format, perl-format
125gettext "Left as an %exercise to {maintainer}.";
126# No xgettext comment this time.
127gettext "Left as an %exercise to {maintainer}.";
128
129# Dollars inside sub argument lists have no effect.
130sub testFunc($) { }
131=item TestBug1
132If you have gettext()'d foo bar test1'...
133=cut
134
135# Dollars inside sub argument lists have no effect.
136testFunc = sub ($) { }
137=item TestBug2
138If you have gettext()'d foo bar test2'...
139=cut
140
141# Dollars inside sub argument lists have no effect.
142sub testFunc($\$;*@) { }
143=item TestBug3
144If you have gettext()'d foo bar test3'...
145=cut
146
147__END__
148gettext "Discarded!";
149EOF
150
151tmpfiles="$tmpfiles xg-pl-1.tmp.po xg-pl-1.po"
152: ${XGETTEXT=xgettext}
153${XGETTEXT} --omit-header -n \
154  -k_ --flag=_:1:pass-perl-format --flag=_:1:pass-perl-brace-format \
155  -k%__ --flag=%__:1:pass-perl-format --flag=%__:1:pass-perl-brace-format \
156  -k\$__ --flag=\$__:1:pass-perl-format --flag=\$__:1:pass-perl-brace-format \
157  -d xg-pl-1.tmp xg-pl-1.pl
158test $? = 0 || { rm -fr $tmpfiles; exit 1; }
159tr -d '\r' < xg-pl-1.tmp.po > xg-pl-1.po
160test $? = 0 || { rm -fr $tmpfiles; exit 1; }
161
162tmpfiles="$tmpfiles xg-pl-1.ok"
163cat <<\EOF > xg-pl-1.ok
164#: xg-pl-1.pl:9
165msgid "'Your command, please?', asked the waiter."
166msgstr ""
167
168#: xg-pl-1.pl:11
169#, perl-format
170msgid "a piece of cake"
171msgid_plural "%d pieces of cake"
172msgstr[0] ""
173msgstr[1] ""
174
175#: xg-pl-1.pl:13
176#, perl-format
177msgid "%s is replaced by %s."
178msgstr ""
179
180#: xg-pl-1.pl:16
181#, perl-format
182msgid "one file deleted"
183msgid_plural "%d files deleted"
184msgstr[0] ""
185msgstr[1] ""
186
187#: xg-pl-1.pl:22
188#, perl-format
189msgid "Singular\n"
190msgid_plural "Plural\n"
191msgstr[0] ""
192msgstr[1] ""
193
194#: xg-pl-1.pl:28
195msgid "Bareword"
196msgstr ""
197
198#: xg-pl-1.pl:30
199msgid "quoted string"
200msgstr ""
201
202#: xg-pl-1.pl:31
203msgid ""
204"weird\n"
205"formatting"
206msgstr ""
207
208#: xg-pl-1.pl:38
209msgid "Welcome to the Republic of Perl!"
210msgstr ""
211
212#: xg-pl-1.pl:42
213msgid "pattern match"
214msgstr ""
215
216#: xg-pl-1.pl:43
217msgid "substitution"
218msgstr ""
219
220#: xg-pl-1.pl:43
221msgid "find me"
222msgstr ""
223
224#: xg-pl-1.pl:50
225msgid "First here document.\n"
226msgstr ""
227
228#: xg-pl-1.pl:52
229msgid "Second here document.\n"
230msgstr ""
231
232#: xg-pl-1.pl:56
233msgid "abc$def"
234msgstr ""
235
236#: xg-pl-1.pl:57
237msgid "abc\\$def"
238msgstr ""
239
240#: xg-pl-1.pl:60
241msgid "abc$defg"
242msgstr ""
243
244#: xg-pl-1.pl:61 xg-pl-1.pl:62
245msgid "abc\\$defg"
246msgstr ""
247
248#: xg-pl-1.pl:63
249msgid "abc\\\\$defg"
250msgstr ""
251
252#: xg-pl-1.pl:66 xg-pl-1.pl:67 xg-pl-1.pl:71 xg-pl-1.pl:72 xg-pl-1.pl:81
253#: xg-pl-1.pl:86
254msgid "ecs\\tasy"
255msgstr ""
256
257#: xg-pl-1.pl:68 xg-pl-1.pl:69 xg-pl-1.pl:73 xg-pl-1.pl:74 xg-pl-1.pl:83
258#: xg-pl-1.pl:88
259msgid "ecs\\\\tasy"
260msgstr ""
261
262#: xg-pl-1.pl:70 xg-pl-1.pl:75
263msgid "ecs\\\\\\tasy"
264msgstr ""
265
266#: xg-pl-1.pl:80 xg-pl-1.pl:85
267msgid "ecs\tasy"
268msgstr ""
269
270#: xg-pl-1.pl:82 xg-pl-1.pl:87
271msgid "ecs\\\tasy"
272msgstr ""
273
274#: xg-pl-1.pl:84 xg-pl-1.pl:89
275msgid "ecs\\\\\tasy"
276msgstr ""
277
278#: xg-pl-1.pl:90 xg-pl-1.pl:95
279msgid "marihuana"
280msgstr ""
281
282#: xg-pl-1.pl:91 xg-pl-1.pl:92 xg-pl-1.pl:96 xg-pl-1.pl:97
283msgid "mari\\huana"
284msgstr ""
285
286#: xg-pl-1.pl:93 xg-pl-1.pl:94 xg-pl-1.pl:98 xg-pl-1.pl:99
287msgid "mari\\\\huana"
288msgstr ""
289
290#: xg-pl-1.pl:102
291#, perl-brace-format
292msgid "This is {only} a brace formatstring."
293msgstr ""
294
295#: xg-pl-1.pl:103
296#, perl-format, perl-brace-format
297msgid "This is %s {mixed}."
298msgstr ""
299
300#: xg-pl-1.pl:104
301#, perl-format
302msgid "This is only %c."
303msgstr ""
304
305#: xg-pl-1.pl:105
306msgid "This is nothing at all."
307msgstr ""
308
309#: xg-pl-1.pl:106
310msgid "And this is %l also no format at all."
311msgstr ""
312
313#: xg-pl-1.pl:109
314#, no-perl-format, perl-brace-format
315msgid "The function '{func}' expects '%c' here."
316msgstr ""
317
318#: xg-pl-1.pl:114 xg-pl-1.pl:116 xg-pl-1.pl:118
319#, perl-format, no-perl-brace-format
320msgid "Left as an %exercise to {maintainer}."
321msgstr ""
322EOF
323
324: ${DIFF=diff}
325${DIFF} xg-pl-1.ok xg-pl-1.po
326result=$?
327
328rm -fr $tmpfiles
329
330exit $result
331