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