Imported Upstream version 0.18.1.1
[platform/upstream/gettext.git] / gettext-tools / tests / plural-1
1 #! /bin/sh
2
3 tmpfiles=""
4 trap 'rm -fr $tmpfiles' 1 2 3 15
5
6 tmpfiles="$tmpfiles cake.tmp cake.pot"
7 : ${XGETTEXT=xgettext}
8 ${XGETTEXT} -o cake.tmp --omit-header --no-location ${top_srcdir}/tests/plural-1-prg.c
9 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
10 LC_ALL=C tr -d '\r' < cake.tmp > cake.pot
11 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
12
13 tmpfiles="$tmpfiles cake.ok"
14 cat <<EOF > cake.ok
15 #, c-format
16 msgid "a piece of cake"
17 msgid_plural "%d pieces of cake"
18 msgstr[0] ""
19 msgstr[1] ""
20 EOF
21
22 : ${DIFF=diff}
23 ${DIFF} cake.ok cake.pot || exit 1
24
25 tmpfiles="$tmpfiles fr.po"
26 cat <<EOF > fr.po
27 # Les gateaux allemands sont les meilleurs du monde.
28 #, c-format
29 msgid "a piece of cake"
30 msgid_plural "%d pieces of cake"
31 msgstr[0] "un morceau de gateau"
32 msgstr[1] "%d morceaux de gateau"
33 EOF
34
35 tmpfiles="$tmpfiles fr.po.tmp fr.po.new"
36 : ${MSGMERGE=msgmerge}
37 ${MSGMERGE} -q -o fr.po.tmp fr.po cake.pot
38 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
39 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new
40 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
41
42 : ${DIFF=diff}
43 ${DIFF} fr.po fr.po.new || exit 1
44
45 tmpfiles="$tmpfiles fr"
46 test -d fr || mkdir fr
47 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
48
49 : ${MSGFMT=msgfmt}
50 ${MSGFMT} -o fr/LC_MESSAGES/cake.mo fr.po
51
52 tmpfiles="$tmpfiles fr.po.tmp fr.po.un"
53 : ${MSGUNFMT=msgunfmt}
54 ${MSGUNFMT} -o fr.po.tmp fr/LC_MESSAGES/cake.mo
55 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
56 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.un
57 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
58
59 tmpfiles="$tmpfiles fr.po.strip"
60 sed 1,2d < fr.po > fr.po.strip
61
62 : ${DIFF=diff}
63 ${DIFF} fr.po.strip fr.po.un || exit 1
64
65 tmpfiles="$tmpfiles cake.ok cake.tmp cake.out"
66 : ${DIFF=diff}
67 echo 'un morceau de gateau' > cake.ok
68 LANGUAGE= ./cake fr 1 > cake.tmp || exit 1
69 LC_ALL=C tr -d '\r' < cake.tmp > cake.out || exit 1
70 ${DIFF} cake.ok cake.out || exit 1
71 echo '2 morceaux de gateau' > cake.ok
72 LANGUAGE= ./cake fr 2 > cake.tmp || exit 1
73 LC_ALL=C tr -d '\r' < cake.tmp > cake.out || exit 1
74 ${DIFF} cake.ok cake.out || exit 1
75 echo '10 morceaux de gateau' > cake.ok
76 LANGUAGE= ./cake fr 10 > cake.tmp || exit 1
77 LC_ALL=C tr -d '\r' < cake.tmp > cake.out || exit 1
78 ${DIFF} cake.ok cake.out || exit 1
79
80 rm -fr $tmpfiles
81
82 exit 0