• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2. "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4# Test checking of Qt plural format strings.
5
6cat <<\EOF > f-qtp-2.data
7# Valid: %1 doesn't count
8msgid  "abc%1def"
9msgstr "xyz"
10# Valid: same arguments
11msgid  "abc%ndef"
12msgstr "xyz%n"
13# Valid: same arguments, L option is ignored
14msgid  "abc%Lndef"
15msgstr "xyz%n"
16# Valid: same arguments, L option is ignored
17msgid  "abc%ndef"
18msgstr "xyz%Ln"
19# Valid: repetition of an argument in the translation
20msgid  "abc%ndef"
21msgstr "xyz%nuvw%n"
22# Valid: removing repeated argument in the translation
23msgid  "abc%ndef%n"
24msgstr "xyz%nuvw"
25# Invalid: too few arguments
26msgid  "abc%ndef"
27msgstr "xyz"
28# Invalid: too many arguments
29msgid  "abcdef"
30msgstr "xyz%nuvw"
31EOF
32
33: ${MSGFMT=msgfmt}
34n=0
35while read comment; do
36  read msgid_line
37  read msgstr_line
38  n=`expr $n + 1`
39  cat <<EOF > f-qtp-2-$n.po
40#, qt-plural-format
41${msgid_line}
42${msgstr_line}
43EOF
44  fail=
45  if echo "$comment" | grep 'Valid:' > /dev/null; then
46    if ${MSGFMT} --check-format -o f-qtp-2-$n.mo f-qtp-2-$n.po; then
47      :
48    else
49      fail=yes
50    fi
51  else
52    ${MSGFMT} --check-format -o f-qtp-2-$n.mo f-qtp-2-$n.po 2> /dev/null
53    if test $? = 1; then
54      :
55    else
56      fail=yes
57    fi
58  fi
59  if test -n "$fail"; then
60    echo "Format string checking error:" 1>&2
61    cat f-qtp-2-$n.po 1>&2
62    Exit 1
63  fi
64  rm -f f-qtp-2-$n.po f-qtp-2-$n.mo
65done < f-qtp-2.data
66
67Exit 0
68