summaryrefslogtreecommitdiffstats
path: root/gettext-tools/tests/format-qt-plural-1
blob: 89bbfc33b8f85382cf5ca9caa91eac92f32825c6 (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
#! /bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test recognition of Qt plural format strings.

cat <<\EOF > f-qtp-1.data
# Unrecognized: no argument
"abcdef"
# Unrecognized: unterminated
"abcdef%"
# Unrecognized: unterminated
"abcdef%L"
# Valid: one argument
"abc%ndef"
# Valid: unterminated
"abc%ndef%"
# Valid: unterminated
"abc%ndef%L"
# Valid: multiple uses of same argument
"abc%ndef%nghi"
# Valid: an argument with locale-dependency flag
"abc%Lndef"
EOF

: ${XGETTEXT=xgettext}
n=0
while read comment; do
  read string
  n=`expr $n + 1`
  cat <<EOF > f-qtp-1-$n.in
_(${string});
EOF
  ${XGETTEXT} -L C++ --qt -k_ -o f-qtp-1-$n.po f-qtp-1-$n.in || exit 1
  test -f f-qtp-1-$n.po || exit 1
  fail=
  if echo "$comment" | grep 'Valid:' > /dev/null; then
    if grep qt-plural-format f-qtp-1-$n.po > /dev/null; then
      :
    else
      fail=yes
    fi
  else
    if grep qt-plural-format f-qtp-1-$n.po > /dev/null; then
      fail=yes
    else
      :
    fi
  fi
  if test -n "$fail"; then
    echo "Format string recognition error:" 1>&2
    cat f-qtp-1-$n.in 1>&2
    echo "Got:" 1>&2
    cat f-qtp-1-$n.po 1>&2
    exit 1
  fi
  rm -f f-qtp-1-$n.in f-qtp-1-$n.po
done < f-qtp-1.data

exit 0