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