summaryrefslogtreecommitdiffstats
path: root/gettext-tools/tests/xgettext-c-15
blob: 97c41b3fc37b2e09e7246988374833abfc6bd11d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! /bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test C support: extraction of contexts specified in GNOME glib syntax.

cat <<\EOF > xg-c-15.c
/* (glib) The 1-argument Q_ macro is a gettext with context. */
print (Q_ ("Printer|Open"));
/* (hypothetical) The 2-argument Q_ macro is an ngettext with contexts. */
print (Q_ ("Menu|Recent File", "Menu|Recent Files"));
EOF

: ${XGETTEXT=xgettext}
${XGETTEXT} --omit-header --no-location \
  --keyword=Q_:1g --keyword=Q_:1g,2g \
  -d xg-c-15.tmp xg-c-15.c || Exit 1
LC_ALL=C tr -d '\r' < xg-c-15.tmp.po > xg-c-15.po || Exit 1

cat <<EOF > xg-c-15.ok
msgctxt "Printer"
msgid "Open"
msgstr ""

msgctxt "Menu"
msgid "Recent File"
msgid_plural "Recent Files"
msgstr[0] ""
msgstr[1] ""
EOF

: ${DIFF=diff}
${DIFF} xg-c-15.ok xg-c-15.po
result=$?

exit $result