Imported Upstream version 0.18.1.1
[platform/upstream/gettext.git] / gettext-tools / tests / xgettext-c-15
1 #! /bin/sh
2
3 # Test C support: extraction of contexts specified in GNOME glib syntax.
4
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
7
8 tmpfiles="$tmpfiles xg-c-15.c"
9 cat <<\EOF > xg-c-15.c
10 /* (glib) The 1-argument Q_ macro is a gettext with context. */
11 print (Q_ ("Printer|Open"));
12 /* (hypothetical) The 2-argument Q_ macro is an ngettext with contexts. */
13 print (Q_ ("Menu|Recent File", "Menu|Recent Files"));
14 EOF
15
16 tmpfiles="$tmpfiles xg-c-15.tmp.po xg-c-15.po"
17 : ${XGETTEXT=xgettext}
18 ${XGETTEXT} --omit-header --no-location \
19   --keyword=Q_:1g --keyword=Q_:1g,2g \
20   -d xg-c-15.tmp xg-c-15.c
21 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
22 LC_ALL=C tr -d '\r' < xg-c-15.tmp.po > xg-c-15.po
23 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
24
25 tmpfiles="$tmpfiles xg-c-15.ok"
26 cat <<EOF > xg-c-15.ok
27 msgctxt "Printer"
28 msgid "Open"
29 msgstr ""
30
31 msgctxt "Menu"
32 msgid "Recent File"
33 msgid_plural "Recent Files"
34 msgstr[0] ""
35 msgstr[1] ""
36 EOF
37
38 : ${DIFF=diff}
39 ${DIFF} xg-c-15.ok xg-c-15.po
40 result=$?
41
42 rm -fr $tmpfiles
43
44 exit $result