#! /bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test ISO C 99 <inttypes.h> format string directives with plural forms.

: ${XGETTEXT=xgettext}
${XGETTEXT} -o fc4.tmp --omit-header --no-location "$abs_srcdir"/format-c-4-prg.c || Exit 1
LC_ALL=C tr -d '\r' < fc4.tmp > fc4.pot || Exit 1

cat <<EOF > fc4.ok
#, c-format
msgid "father of %<PRId8> child"
msgid_plural "father of %<PRId8> children"
msgstr[0] ""
msgstr[1] ""
EOF

: ${DIFF=diff}
${DIFF} fc4.ok fc4.pot || Exit 1

cat <<EOF > fc4-de.po
#, c-format
msgid "father of %<PRId8> child"
msgid_plural "father of %<PRId8> children"
msgstr[0] "Vater eines Kindes"
msgstr[1] "Vater von %<PRId8> Kindern"
EOF

test -d fc4-dir || mkdir fc4-dir
test -d fc4-dir/de || mkdir fc4-dir/de
test -d fc4-dir/de/LC_MESSAGES || mkdir fc4-dir/de/LC_MESSAGES

: ${MSGFMT=msgfmt}
${MSGFMT} -o fc4-dir/de/LC_MESSAGES/fc4.mo fc4-de.po

: ${MSGUNFMT=msgunfmt}
${MSGUNFMT} -o fc4-de.po.tmp fc4-dir/de/LC_MESSAGES/fc4.mo || Exit 1
LC_ALL=C tr -d '\r' < fc4-de.po.tmp > fc4-de.po.un || Exit 1

: ${DIFF=diff}
${DIFF} fc4-de.po fc4-de.po.un || Exit 1

LANGUAGE= ../fc4 de_DE
result=$?

exit $result
