xref: /netbsd-src/external/gpl2/gettext/dist/gettext-tools/tests/xgettext-c-10 (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
1#! /bin/sh
2
3# Test C support: extraction of contexts.
4
5tmpfiles=""
6trap 'rm -fr $tmpfiles' 1 2 3 15
7
8tmpfiles="$tmpfiles xg-c-10.c"
9cat <<\EOF > xg-c-10.c
10// (KDE) The 1-argument i18n macro is a simple gettext without context.
11print (i18n ("help"));
12// (KDE) The 2-argument i18n macro has the context first.
13print (i18n ("Help", "about"));
14// (Qt) The 2-argument tr function has the context last.
15print (tr ("file"));
16print (tr ("open", "File"));
17EOF
18
19tmpfiles="$tmpfiles xg-c-10.po"
20: ${XGETTEXT=xgettext}
21${XGETTEXT} --omit-header --no-location \
22  --keyword=i18n:1 --keyword=i18n:1c,2 --keyword=tr:1 --keyword=tr:1,2c \
23  -d xg-c-10 xg-c-10.c
24test $? = 0 || { rm -fr $tmpfiles; exit 1; }
25
26tmpfiles="$tmpfiles xg-c-10.ok"
27cat <<EOF > xg-c-10.ok
28msgid "help"
29msgstr ""
30
31msgctxt "Help"
32msgid "about"
33msgstr ""
34
35msgid "file"
36msgstr ""
37
38msgctxt "File"
39msgid "open"
40msgstr ""
41EOF
42
43: ${DIFF=diff}
44${DIFF} xg-c-10.ok xg-c-10.po
45result=$?
46
47rm -fr $tmpfiles
48
49exit $result
50