Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / msgexec-5
1 #! /bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Test msgexec on a PO file with plurals.
5
6 cat <<\EOF > mex-test5.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 cat <<\EOF > mex-test5.sh
32 #! /bin/sh
33 echo "========================= $MSGEXEC_LOCATION =========================" | LC_ALL=C tr -d '\r'
34 if test -n "${MSGEXEC_MSGCTXT+set}"; then
35   echo "context: $MSGEXEC_MSGCTXT" | LC_ALL=C tr -d '\r'
36 fi
37 cat <<MEOF
38 $MSGEXEC_MSGID
39 $MSGEXEC_MSGID_PLURAL
40 $MSGEXEC_PLURAL_FORM
41 $MSGEXEC_PREV_MSGID
42 $MSGEXEC_PREV_MSGID_PLURAL
43 ---
44 MEOF
45 cat
46 echo | LC_ALL=C tr -d '\r'
47 exit 0
48 EOF
49 chmod a+x mex-test5.sh
50
51 : ${MSGEXEC=msgexec}
52 LC_ALL=C \
53 ${MSGEXEC} -i mex-test5.po ./mex-test5.sh > mex-test5.out 2> mex-test5.err
54 result=$?
55 cat mex-test5.err | grep -v 'warning: Locale charset' | grep -v '^ '
56 test $result = 0 || { exit 1; }
57
58 cat <<\EOF > mex-test5.ok
59 ========================= mex-test5.po:2 =========================
60
61
62
63
64
65 ---
66 Content-Type: text/plain; charset=ASCII
67 Plural-Forms: nplurals=2; plural=(n > 1);
68
69 ========================= mex-test5.po:8 =========================
70 'Your command, please?', asked the waiter.
71
72
73
74
75 ---
76 'Votre commande, s'il vous plait', dit le garcon.
77 ========================= mex-test5.po:16 =========================
78 a piece of cake
79 %d pieces of cake
80 0
81 a piece of bread
82 %d pieces of bread
83 ---
84 un morceau de gateau
85 ========================= mex-test5.po:16 =========================
86 a piece of cake
87 %d pieces of cake
88 1
89 a piece of bread
90 %d pieces of bread
91 ---
92 %d morceaux de gateau
93 ========================= mex-test5.po:22 =========================
94 %s is replaced by %s.
95
96
97
98
99 ---
100 %2$s remplace %1$s.
101 EOF
102
103 : ${DIFF=diff}
104 ${DIFF} mex-test5.ok mex-test5.out
105 result=$?
106
107 exit $result