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