format-perl-mixed-1 [plain text]
#! /bin/sh
tmpfiles=""
trap 'rm -fr $tmpfiles' 1 2 3 15
tmpfiles="$tmpfiles f-pm-1.data"
cat <<\EOF > f-pm-1.data
"{foo} %c {bar} %d {baz}"
"%c %d"
"{foo%cbar}"
"{foo%cbar} {baz}"
"{foo} %l {bar}"
"{foo bar %l"
EOF
: ${XGETTEXT=xgettext}
n=0
while read comment; do
read formats
read string
n=`expr $n + 1`
tmpfiles="$tmpfiles f-pm-1-$n.in f-pm-1-$n.po"
cat <<EOF > f-pm-1-$n.in
gettext(${string});
EOF
${XGETTEXT} -L perl --omit-header --no-location -o f-pm-1-$n.po f-pm-1-$n.in || exit 1
test -f f-pm-1-$n.po || exit 1
fail=
if test -n "${formats}"; then
if sed 1q < f-pm-1-$n.po | grep '^'"${formats}"'$' > /dev/null; then
:
else
fail=yes
fi
else
if sed 1q < f-pm-1-$n.po | grep '^msgid' > /dev/null; then
:
else
fail=yes
fi
fi
if test -n "$fail"; then
echo "Format string recognition error:" 1>&2
cat f-pm-1-$n.in 1>&2
echo "Got:" 1>&2
cat f-pm-1-$n.po 1>&2
exit 1
fi
done < f-pm-1.data
rm -fr $tmpfiles
exit 0