summaryrefslogtreecommitdiffstats
path: root/gettext-tools/tests/msgfilter-6
blob: 357dd45d18acd47ad319ca4db77350fefdd1fb22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#! /bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test msgfilter on a PO file with plurals.

cat <<\EOF > mf-test6.po
msgid ""
msgstr ""
"Content-Type: text/plain; charset=ASCII\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#, c-format
msgid "'Your command, please?', asked the waiter."
msgstr "'Votre commande, s'il vous plait', dit le garcon."

# Les gateaux allemands sont les meilleurs du monde.
#, c-format
#| msgid "a piece of bread"
#| msgid_plural "%d pieces of bread"
msgid "a piece of cake"
msgid_plural "%d pieces of cake"
msgstr[0] "un morceau de gateau"
msgstr[1] "%d morceaux de gateau"

# Reverse the arguments.
#, c-format
msgid "%s is replaced by %s."
msgstr "%2$s remplace %1$s."
EOF

: > mf-test6.tmp

cat <<\EOF > mf-test6.sh
#! /bin/sh
echo "========================= $MSGFILTER_LOCATION =========================" >> mf-test6.tmp
if test -n "${MSGFILTER_MSGCTXT+set}"; then
  echo "context: $MSGFILTER_MSGCTXT" >> mf-test6.tmp
fi
cat >> mf-test6.tmp <<MEOF
$MSGFILTER_MSGID
$MSGFILTER_MSGID_PLURAL
$MSGFILTER_PLURAL_FORM
$MSGFILTER_PREV_MSGID
$MSGFILTER_PREV_MSGID_PLURAL
MEOF
cat
EOF
chmod a+x mf-test6.sh

: ${MSGFILTER=msgfilter}
LC_ALL=C \
${MSGFILTER} -i mf-test6.po ./mf-test6.sh >/dev/null 2> mf-test6.err
result=$?

cat mf-test6.err | grep -v 'warning: Locale charset' | grep -v '^ '
test $result = 0 || { Exit 1; }

LC_ALL=C tr -d '\r' < mf-test6.tmp > mf-test6.out

cat <<\EOF > mf-test6.ok
========================= mf-test6.po:2 =========================





========================= mf-test6.po:8 =========================
'Your command, please?', asked the waiter.




========================= mf-test6.po:16 =========================
a piece of cake
%d pieces of cake
0
a piece of bread
%d pieces of bread
========================= mf-test6.po:16 =========================
a piece of cake
%d pieces of cake
1
a piece of bread
%d pieces of bread
========================= mf-test6.po:22 =========================
%s is replaced by %s.




EOF

: ${DIFF=diff}
${DIFF} mf-test6.ok mf-test6.out
result=$?

exit $result