Imported Upstream version 0.18.1.1
[platform/upstream/gettext.git] / gettext-tools / tests / xgettext-c-11
1 #! /bin/sh
2
3 # Test C support: extraction of contexts, disambiguating according to the
4 # argument count.
5
6 tmpfiles=""
7 trap 'rm -fr $tmpfiles' 1 2 3 15
8
9 tmpfiles="$tmpfiles xg-c-11.c"
10 cat <<\EOF > xg-c-11.c
11 // (KDE) The 1-argument i18n macro is a simple gettext without context.
12 print (i18n ("help"));
13 // (KDE) The 2-argument i18n macro has the context first.
14 print (i18n ("Help", "about"));
15 // (KDE) The 3-argument i18n macro is an ngettext without context.
16 print (i18n ("error", "errors", 7));
17 EOF
18
19 tmpfiles="$tmpfiles xg-c-11.tmp.po xg-c-11.po"
20 : ${XGETTEXT=xgettext}
21 ${XGETTEXT} --omit-header --no-location \
22   --keyword=i18n:1 --keyword=i18n:1c,2,2t --keyword=i18n:1,2,3t \
23   -d xg-c-11.tmp xg-c-11.c
24 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
25 LC_ALL=C tr -d '\r' < xg-c-11.tmp.po > xg-c-11.po
26 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
27
28 tmpfiles="$tmpfiles xg-c-11.ok"
29 cat <<EOF > xg-c-11.ok
30 msgid "help"
31 msgstr ""
32
33 msgctxt "Help"
34 msgid "about"
35 msgstr ""
36
37 msgid "error"
38 msgid_plural "errors"
39 msgstr[0] ""
40 msgstr[1] ""
41 EOF
42
43 : ${DIFF=diff}
44 ${DIFF} xg-c-11.ok xg-c-11.po
45 result=$?
46
47 rm -fr $tmpfiles
48
49 exit $result