• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2. "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4# Test recognition of KUIT format strings.
5
6: ${XGETTEXT=xgettext}
7
8cat <<\EOF > f-kd-invalid.cpp
9xi18n("<invalid>");
10EOF
11
12LC_ALL=C ${XGETTEXT} -L C++ --kde --flag=xi18n:1:kde-kuit-format -o - f-kd-invalid.cpp 2>&1 | grep 'not a valid KDE KUIT format' > /dev/null 2>&1
13test $? = 0 || {
14  echo "Skipping test: xgettext was built without KDE KUIT format support"
15  Exit 77
16}
17
18cat <<\EOF > f-kd-1.data
19# Unrecognized: unbalanced filename tag
20"<filename>a"
21# Unrecognized: unbalanced filename tag
22"<filename>%1"
23# Unrecognized: unbalanced filename tag
24"<filename>%1</xfilename>"
25# Valid: one argument
26"<filename>%1</filename>"
27# Valid: accelerator
28"<command>&Application.About</command>"
29# Valid: accelerator at the end
30"<command>About</command>&A"
31# Valid: accelerator
32"<command>&/</command>"
33# Valid: entity reference
34"<command>&amp;About</command>"
35# Valid: character reference
36"<command>&#x2A;&#x2a;&#x61;&#141;</command>"
37EOF
38
39n=0
40while read comment; do
41  read string
42  n=`expr $n + 1`
43  cat <<EOF > f-kd-1-$n.in
44xi18n(${string});
45EOF
46  ${XGETTEXT} -L C++ --kde --flag=xi18n:1:kde-kuit-format --flag=i18n:1:kde-format -kxi18n -ki18n -o f-kd-1-$n.po f-kd-1-$n.in || Exit 1
47  test -f f-kd-1-$n.po || Exit 1
48  fail=
49  if echo "$comment" | grep 'Valid:' > /dev/null; then
50    if grep kde-kuit-format f-kd-1-$n.po > /dev/null; then
51      :
52    else
53      fail=yes
54    fi
55  else
56    if grep kde-kuit-format f-kd-1-$n.po > /dev/null; then
57      fail=yes
58    else
59      :
60    fi
61  fi
62  if test -n "$fail"; then
63    echo "Format string recognition error:" 1>&2
64    cat f-kd-1-$n.in 1>&2
65    echo "Got:" 1>&2
66    cat f-kd-1-$n.po 1>&2
67    Exit 1
68  fi
69  rm -f f-kd-1-$n.in f-kd-1-$n.po
70done < f-kd-1.data
71
72Exit 0
73