xref: /netbsd-src/external/gpl2/gettext/dist/gettext-tools/tests/xgettext-python-2 (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
1#!/bin/sh
2
3# Test Python support: --add-comments option.
4
5tmpfiles=""
6trap 'rm -fr $tmpfiles' 1 2 3 15
7
8tmpfiles="$tmpfiles xg-py-2.py"
9cat <<EOF > xg-py-2.py
10# This comment will not be extracted.
11print gettext.gettext("help")
12#  TRANSLATORS: This is an extracted comment.
13print gettext.gettext("me")
14# Not extracted either.
15print gettext.gettext("Hey Jude")
16# TRANSLATORS:
17#    Nickname of the Beatles
18print gettext.gettext("The Fabulous Four")
19# TRANSLATORS: The strings get concatenated.
20print gettext.gettext("there is not enough"
21" room on a single line for this entire long, " # confusing, eh?
22"verbose string")
23EOF
24
25tmpfiles="$tmpfiles xg-py-2.po"
26: ${XGETTEXT=xgettext}
27${XGETTEXT} --omit-header --no-location --add-comments=TRANSLATORS: \
28  -d xg-py-2 xg-py-2.py
29test $? = 0 || { rm -fr $tmpfiles; exit 1; }
30
31tmpfiles="$tmpfiles xg-py-2.ok"
32cat <<EOF > xg-py-2.ok
33msgid "help"
34msgstr ""
35
36#. TRANSLATORS: This is an extracted comment.
37msgid "me"
38msgstr ""
39
40msgid "Hey Jude"
41msgstr ""
42
43#. TRANSLATORS:
44#. Nickname of the Beatles
45msgid "The Fabulous Four"
46msgstr ""
47
48#. TRANSLATORS: The strings get concatenated.
49msgid ""
50"there is not enough room on a single line for this entire long, verbose "
51"string"
52msgstr ""
53EOF
54
55: ${DIFF=diff}
56${DIFF} xg-py-2.ok xg-py-2.po
57result=$?
58
59rm -fr $tmpfiles
60
61exit $result
62