Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / msgfilter-6
1 #! /bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Test msgfilter on a PO file with plurals.
5
6 cat <<\EOF > mf-test6.po
7 msgid ""
8 msgstr ""
9 "Content-Type: text/plain; charset=ASCII\n"
10 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
11
12 #, c-format
13 msgid "'Your command, please?', asked the waiter."
14 msgstr "'Votre commande, s'il vous plait', dit le garcon."
15
16 # Les gateaux allemands sont les meilleurs du monde.
17 #, c-format
18 #| msgid "a piece of bread"
19 #| msgid_plural "%d pieces of bread"
20 msgid "a piece of cake"
21 msgid_plural "%d pieces of cake"
22 msgstr[0] "un morceau de gateau"
23 msgstr[1] "%d morceaux de gateau"
24
25 # Reverse the arguments.
26 #, c-format
27 msgid "%s is replaced by %s."
28 msgstr "%2$s remplace %1$s."
29 EOF
30
31 : > mf-test6.tmp
32
33 cat <<\EOF > mf-test6.sh
34 #! /bin/sh
35 echo "========================= $MSGFILTER_LOCATION =========================" >> mf-test6.tmp
36 if test -n "${MSGFILTER_MSGCTXT+set}"; then
37   echo "context: $MSGFILTER_MSGCTXT" >> mf-test6.tmp
38 fi
39 cat >> mf-test6.tmp <<MEOF
40 $MSGFILTER_MSGID
41 $MSGFILTER_MSGID_PLURAL
42 $MSGFILTER_PLURAL_FORM
43 $MSGFILTER_PREV_MSGID
44 $MSGFILTER_PREV_MSGID_PLURAL
45 MEOF
46 cat
47 EOF
48 chmod a+x mf-test6.sh
49
50 : ${MSGFILTER=msgfilter}
51 LC_ALL=C \
52 ${MSGFILTER} -i mf-test6.po ./mf-test6.sh >/dev/null 2> mf-test6.err
53 result=$?
54
55 cat mf-test6.err | grep -v 'warning: Locale charset' | grep -v '^ '
56 test $result = 0 || { exit 1; }
57
58 LC_ALL=C tr -d '\r' < mf-test6.tmp > mf-test6.out
59
60 cat <<\EOF > mf-test6.ok
61 ========================= mf-test6.po:2 =========================
62
63
64
65
66
67 ========================= mf-test6.po:8 =========================
68 'Your command, please?', asked the waiter.
69
70
71
72
73 ========================= mf-test6.po:16 =========================
74 a piece of cake
75 %d pieces of cake
76 0
77 a piece of bread
78 %d pieces of bread
79 ========================= mf-test6.po:16 =========================
80 a piece of cake
81 %d pieces of cake
82 1
83 a piece of bread
84 %d pieces of bread
85 ========================= mf-test6.po:22 =========================
86 %s is replaced by %s.
87
88
89
90
91 EOF
92
93 : ${DIFF=diff}
94 ${DIFF} mf-test6.ok mf-test6.out
95 result=$?
96
97 exit $result