Imported Upstream version 0.18.1.1
[platform/upstream/gettext.git] / gettext-tools / tests / msgfilter-1
1 #! /bin/sh
2
3 # Test general filter execution.
4
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
7
8 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
9   # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
10   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
11     ac_n= ac_c='
12 ' ac_t='        '
13   else
14     ac_n=-n ac_c= ac_t=
15   fi
16 else
17   ac_n= ac_c='\c' ac_t=
18 fi
19
20 # Some fold programs (like SunOS4 and FreeBSD) don't have an option to wrap at
21 # spaces.
22 echo abc | fold -b -s -w 20 >/dev/null 2>&1 || {
23   echo "Skipping test: fold program not POSIX compliant"
24   rm -fr $tmpfiles; exit 77
25 }
26
27 # Some fold programs (like NetBSD 5.0) remove trailing spaces when wrapping.
28 echo ab cd | fold -b -s -w 3 | grep ' ' >/dev/null || {
29   echo "Skipping test: fold program trims trailing spaces"
30   rm -fr $tmpfiles; exit 77
31 }
32
33 # Some fold programs (like HP-UX) insert a newline at the end, if the last
34 # line was not terminated with a newline and the -s option was given.
35 foldoutputcount=`echo $ac_n "abc$ac_c" | fold -b -s -w 20 | wc -c`
36 foldoutputcount=`echo "$foldoutputcount" | sed -e 's/[  ]//g'`
37 test "$foldoutputcount" = 3 || {
38   echo "Skipping test: fold program inserts extra newline"
39   rm -fr $tmpfiles; exit 77
40 }
41
42 tmpfiles="$tmpfiles mfi-test1.po"
43 cat <<\EOF > mfi-test1.po
44 # HEADER.
45 #
46 msgid ""
47 msgstr ""
48 "Project-Id-Version: Bonnie Tyler\n"
49 "Content-Type: text/plain; charset=ISO-8859-1\n"
50 "Content-Transfer-Encoding: 8bit\n"
51
52 #: married-men:4
53 #, fuzzy
54 msgid "The world is full of married men"
55 msgstr "So viele verheiratete Männer"
56
57 #: married-men:5
58 msgid "with wives who never understand"
59 msgstr "und ihre Frauen verstehen sie nicht"
60
61 #: married-men:6
62 msgid "They're looking for someone to share"
63 msgstr ""
64
65 # schwer zu übersetzen...
66 #: married-men:7
67 msgid "the excitement of a love affair"
68 msgstr ""
69
70 #: married-men:8
71 msgid "Just as soon as they find you"
72 msgstr ""
73
74 #: married-men:9
75 msgid "They warn you and darn you"
76 msgstr ""
77
78 #~ msgid "You fly on the wings of romance"
79 #~ msgstr "Die Flügel der frischen Liebe heben dich zum Himmel"
80
81 #, fuzzy
82 #~ msgid "In the eyes of the world"
83 #~ msgstr "Für die anderen"
84
85 # Etwas freie Übersetzung.
86 #~ msgid "You're just another crazy girl"
87 #~ msgstr "bist du bloß ein verrücktes dummes Ding"
88
89 #~ msgid "Who loves a married man"
90 #~ msgstr "das einen verheirateten Mann liebt"
91 EOF
92
93 tmpfiles="$tmpfiles mfi-test1.out mfi-test1.err"
94 : ${MSGFILTER=msgfilter}
95 LC_ALL=C \
96 ${MSGFILTER} -i mfi-test1.po -o mfi-test1.out fold -b -s -w 20 >mfi-test1.err 2>&1
97 result=$?
98 cat mfi-test1.err | grep -v 'warning: Locale charset' | grep -v '^ '
99 test $result = 0 || { rm -fr $tmpfiles; exit 1; }
100
101 tmpfiles="$tmpfiles mfi-test1.ok"
102 cat <<\EOF > mfi-test1.ok
103 # HEADER.
104 #
105 msgid ""
106 msgstr ""
107 "Project-Id-Version: \n"
108 "Bonnie Tyler\n"
109 "Content-Type: \n"
110 "text/plain; \n"
111 "charset=ISO-8859-1\n"
112 "Content-Transfer-Enc\n"
113 "oding: 8bit\n"
114
115 #: married-men:4
116 #, fuzzy
117 msgid "The world is full of married men"
118 msgstr ""
119 "So viele \n"
120 "verheiratete Männer"
121
122 #: married-men:5
123 msgid "with wives who never understand"
124 msgstr ""
125 "und ihre Frauen \n"
126 "verstehen sie nicht"
127
128 #: married-men:6
129 msgid "They're looking for someone to share"
130 msgstr ""
131
132 # schwer zu übersetzen...
133 #: married-men:7
134 msgid "the excitement of a love affair"
135 msgstr ""
136
137 #: married-men:8
138 msgid "Just as soon as they find you"
139 msgstr ""
140
141 #: married-men:9
142 msgid "They warn you and darn you"
143 msgstr ""
144
145 #~ msgid "You fly on the wings of romance"
146 #~ msgstr ""
147 #~ "Die Flügel der \n"
148 #~ "frischen Liebe \n"
149 #~ "heben dich zum \n"
150 #~ "Himmel"
151
152 #, fuzzy
153 #~ msgid "In the eyes of the world"
154 #~ msgstr "Für die anderen"
155
156 # Etwas freie Übersetzung.
157 #~ msgid "You're just another crazy girl"
158 #~ msgstr ""
159 #~ "bist du bloß ein \n"
160 #~ "verrücktes dummes \n"
161 #~ "Ding"
162
163 #~ msgid "Who loves a married man"
164 #~ msgstr ""
165 #~ "das einen \n"
166 #~ "verheirateten Mann \n"
167 #~ "liebt"
168 EOF
169
170 : ${DIFF=diff}
171 ${DIFF} mfi-test1.ok mfi-test1.out
172 result=$?
173
174 rm -fr $tmpfiles
175
176 exit $result