Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / format-kde-2
1 #! /bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Test checking of KDE format strings.
5
6 cat <<\EOF > f-kd-2.data
7 # Valid: %% doesn't count
8 msgid  "abc%%def"
9 msgstr "xyz"
10 # Valid: digit sequence starting with 0 doesn't count
11 msgid  "abc%09def"
12 msgstr "xyz"
13 # Valid: digit sequence starting with 0 doesn't count
14 msgid  "abc%0"
15 msgstr "xyz"
16 # Valid: digit sequence starting with 0 doesn't count
17 msgid  "abc%00"
18 msgstr "xyz"
19 # Valid: L is not a recognized flag
20 msgid  "abc%L1def"
21 msgstr "xyz"
22 # Valid: same arguments
23 msgid  "abc%2def"
24 msgstr "xyz%2"
25 # Invalid: different arguments
26 msgid  "abc%2def"
27 msgstr "xyz%1"
28 # Invalid: different arguments
29 msgid  "abc%1def"
30 msgstr "xyz%2"
31 # Valid: repetition of an argument in the translation
32 msgid  "abc%2def"
33 msgstr "xyz%2uvw%2"
34 # Valid: removing repeated argument in the translation
35 msgid  "abc%2def%2"
36 msgstr "xyz%2uvw"
37 # Valid: permutation
38 msgid  "abc%3%1%2def"
39 msgstr "xyz%2%1%3"
40 # Invalid: too few arguments
41 msgid  "abc%2def%1ghi%3"
42 msgstr "xyz%1"
43 # Invalid: only one argument removed (valid only in singular form)
44 msgid  "abc%2def%1ghi%3"
45 msgstr "xyz%1uvw%2"
46 # Invalid: only one argument removed (valid only in singular form)
47 msgid  "abc%2def%1ghi%3"
48 msgstr "xyz%1uvw%3"
49 # Invalid: only one argument removed (valid only in singular form)
50 msgid  "abc%2def%1ghi%3"
51 msgstr "xyz%3uvw%2"
52 # Invalid: only one argument removed (valid only in singular form)
53 msgid  "abc%1def%3"
54 msgstr "xyz%1"
55 # Invalid: wrong argument removed
56 msgid  "abc%1def%3"
57 msgstr "xyz%3"
58 # Invalid: too many arguments
59 msgid  "abc%1def"
60 msgstr "xyz%1uvw%2"
61 # Invalid: missing non-final argument (valid only in singular form)
62 msgid  "abc%2def%1"
63 msgstr "xyz%2"
64 # Invalid: added non-final argument
65 msgid  "abc%2def"
66 msgstr "xyz%1%2"
67 EOF
68
69 : ${MSGFMT=msgfmt}
70 n=0
71 while 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}
79 EOF
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
101 done < f-kd-2.data
102
103 exit 0