• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2. "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4# Test checking of KDE format strings.
5
6cat <<\EOF > f-kd-2.data
7# Valid: %% doesn't count
8msgid  "abc%%def"
9msgstr "xyz"
10# Valid: digit sequence starting with 0 doesn't count
11msgid  "abc%09def"
12msgstr "xyz"
13# Valid: digit sequence starting with 0 doesn't count
14msgid  "abc%0"
15msgstr "xyz"
16# Valid: digit sequence starting with 0 doesn't count
17msgid  "abc%00"
18msgstr "xyz"
19# Valid: L is not a recognized flag
20msgid  "abc%L1def"
21msgstr "xyz"
22# Valid: same arguments
23msgid  "abc%2def"
24msgstr "xyz%2"
25# Invalid: different arguments
26msgid  "abc%2def"
27msgstr "xyz%1"
28# Invalid: different arguments
29msgid  "abc%1def"
30msgstr "xyz%2"
31# Valid: repetition of an argument in the translation
32msgid  "abc%2def"
33msgstr "xyz%2uvw%2"
34# Valid: removing repeated argument in the translation
35msgid  "abc%2def%2"
36msgstr "xyz%2uvw"
37# Valid: permutation
38msgid  "abc%3%1%2def"
39msgstr "xyz%2%1%3"
40# Invalid: too few arguments
41msgid  "abc%2def%1ghi%3"
42msgstr "xyz%1"
43# Invalid: only one argument removed (valid only in singular form)
44msgid  "abc%2def%1ghi%3"
45msgstr "xyz%1uvw%2"
46# Invalid: only one argument removed (valid only in singular form)
47msgid  "abc%2def%1ghi%3"
48msgstr "xyz%1uvw%3"
49# Invalid: only one argument removed (valid only in singular form)
50msgid  "abc%2def%1ghi%3"
51msgstr "xyz%3uvw%2"
52# Invalid: only one argument removed (valid only in singular form)
53msgid  "abc%1def%3"
54msgstr "xyz%1"
55# Invalid: wrong argument removed
56msgid  "abc%1def%3"
57msgstr "xyz%3"
58# Invalid: too many arguments
59msgid  "abc%1def"
60msgstr "xyz%1uvw%2"
61# Invalid: missing non-final argument (valid only in singular form)
62msgid  "abc%2def%1"
63msgstr "xyz%2"
64# Invalid: added non-final argument
65msgid  "abc%2def"
66msgstr "xyz%1%2"
67EOF
68
69: ${MSGFMT=msgfmt}
70n=0
71while read comment; do
72  read msgid_line
73  read msgstr_line
74  n=`expr $n + 1`
75  cat <<EOF > f-kd-2-$n.po
76#, kde-format
77${msgid_line}
78${msgstr_line}
79EOF
80  fail=
81  if echo "$comment" | grep 'Valid:' > /dev/null; then
82    if ${MSGFMT} --check-format -o f-kd-2-$n.mo f-kd-2-$n.po; then
83      :
84    else
85      fail=yes
86    fi
87  else
88    ${MSGFMT} --check-format -o f-kd-2-$n.mo f-kd-2-$n.po 2> /dev/null
89    if test $? = 1; then
90      :
91    else
92      fail=yes
93    fi
94  fi
95  if test -n "$fail"; then
96    echo "Format string checking error:" 1>&2
97    cat f-kd-2-$n.po 1>&2
98    Exit 1
99  fi
100  rm -f f-kd-2-$n.po f-kd-2-$n.mo
101done < f-kd-2.data
102
103Exit 0
104