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

# Test C support: extraction of contexts specified in GNOME glib syntax.

cat <<\EOF > xg-c-15.c
/* (glib) The 1-argument Q_ macro is a gettext with context. */
print (Q_ ("Printer|Open"));
/* (hypothetical) The 2-argument Q_ macro is an ngettext with contexts. */
print (Q_ ("Menu|Recent File", "Menu|Recent Files"));
EOF

: ${XGETTEXT=xgettext}
${XGETTEXT} --omit-header --no-location \
  --keyword=Q_:1g --keyword=Q_:1g,2g \
  -d xg-c-15.tmp xg-c-15.c || Exit 1
LC_ALL=C tr -d '\r' < xg-c-15.tmp.po > xg-c-15.po || Exit 1

cat <<EOF > xg-c-15.ok
msgctxt "Printer"
msgid "Open"
msgstr ""

msgctxt "Menu"
msgid "Recent File"
msgid_plural "Recent Files"
msgstr[0] ""
msgstr[1] ""
EOF

: ${DIFF=diff}
${DIFF} xg-c-15.ok xg-c-15.po
result=$?

exit $result
