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