Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / xgettext-python-3
1 #!/bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Test Python support: --from-code option and encoding recognition.
5
6 cat <<\EOF > xg-py-3a.py
7 #!/usr/bin/env python
8 # TRANSLATORS: Fran\8f«®ois Pinard is a hero.
9 print gettext.gettext("ÆüËܸì");
10 EOF
11
12 cat <<\EOF > xg-py-3b.py
13 #!/usr/bin/env python
14                        # Hey Emacs! -*- coding: euc-jp -*-
15 # TRANSLATORS: Fran\8f«®ois Pinard is a hero.
16 print gettext.gettext("ÆüËܸì");
17 EOF
18
19 cat <<\EOF > xg-py-3.ok
20 # SOME DESCRIPTIVE TITLE.
21 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
22 # This file is distributed under the same license as the PACKAGE package.
23 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
24 #
25 #, fuzzy
26 msgid ""
27 msgstr ""
28 "Project-Id-Version: PACKAGE VERSION\n"
29 "Report-Msgid-Bugs-To: \n"
30 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
31 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
32 "Language-Team: LANGUAGE <LL@li.org>\n"
33 "Language: \n"
34 "MIME-Version: 1.0\n"
35 "Content-Type: text/plain; charset=UTF-8\n"
36 "Content-Transfer-Encoding: 8bit\n"
37
38 #. TRANSLATORS: François Pinard is a hero.
39 msgid "日本語"
40 msgstr ""
41 EOF
42
43 # Verify that if the source file has no magic coding comment, xgettext fails
44 # if no --from-code option is given but succeeds if it is given.
45 : ${XGETTEXT=xgettext}
46 ${XGETTEXT} --add-comments=TRANSLATORS: --no-location \
47   -d xg-py-3a xg-py-3a.py > /dev/null 2>&1
48 test $? = 1 || { exit 1; }
49 ${XGETTEXT} --add-comments=TRANSLATORS: --no-location --from-code=euc-jp \
50   -o xg-py-3a.tmp xg-py-3a.py || exit 1
51 # Don't simplify this to "grep ... < xg-py-3a.tmp", otherwise OpenBSD 4.0 grep
52 # only outputs "Binary file (standard input) matches".
53 cat xg-py-3a.tmp | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > xg-py-3a.pot
54
55 : ${DIFF=diff}
56 ${DIFF} xg-py-3.ok xg-py-3a.pot || exit 1
57
58 # Verify that if the source file has a magic coding comment, xgettext succeeds.
59
60 ${XGETTEXT} --add-comments=TRANSLATORS: --no-location \
61   -o xg-py-3b.tmp xg-py-3b.py || exit 1
62 # Don't simplify this to "grep ... < xg-py-3b.tmp", otherwise OpenBSD 4.0 grep
63 # only outputs "Binary file (standard input) matches".
64 cat xg-py-3b.tmp | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > xg-py-3b.pot
65
66 ${DIFF} xg-py-3.ok xg-py-3b.pot || exit 1
67
68 # Verify that if the source file has a magic coding comment and a --from-code
69 # option is given, the magic coding comment takes precedence over it.
70
71 ${XGETTEXT} --add-comments=TRANSLATORS: --no-location --from-code=iso-8859-1 \
72   -o xg-py-3c.tmp xg-py-3b.py || exit 1
73 # Don't simplify this to "grep ... < xg-py-3c.tmp", otherwise OpenBSD 4.0 grep
74 # only outputs "Binary file (standard input) matches".
75 cat xg-py-3c.tmp | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > xg-py-3c.pot
76
77 ${DIFF} xg-py-3.ok xg-py-3c.pot || exit 1
78
79 # Verify that backslashes in and second bytes with value 0x5C are correctly
80 # distinguished in weird encodings like BIG5.
81
82 cat <<\EOF > xg-py-3d.py
83 #!/usr/bin/env python
84                        # Hey Emacs! -*- coding: big5 -*-
85 print gettext.gettext(u"¬\u0021");
86 print gettext.gettext(u"¬\\u0021");
87 EOF
88
89 ${XGETTEXT} --add-comments=TRANSLATORS: \
90   -o xg-py-3d.tmp xg-py-3d.py || exit 1
91 # Don't simplify this to "grep ... < xg-py-3d.tmp", otherwise OpenBSD 4.0 grep
92 # only outputs "Binary file (standard input) matches".
93 cat xg-py-3d.tmp | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > xg-py-3d.pot
94
95 cat <<\EOF > xg-py-3d.ok
96 # SOME DESCRIPTIVE TITLE.
97 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
98 # This file is distributed under the same license as the PACKAGE package.
99 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
100 #
101 #, fuzzy
102 msgid ""
103 msgstr ""
104 "Project-Id-Version: PACKAGE VERSION\n"
105 "Report-Msgid-Bugs-To: \n"
106 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
107 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
108 "Language-Team: LANGUAGE <LL@li.org>\n"
109 "Language: \n"
110 "MIME-Version: 1.0\n"
111 "Content-Type: text/plain; charset=UTF-8\n"
112 "Content-Transfer-Encoding: 8bit\n"
113
114 #: xg-py-3d.py:3
115 msgid "枯u0021"
116 msgstr ""
117
118 #: xg-py-3d.py:4
119 msgid "枯!"
120 msgstr ""
121 EOF
122
123 ${DIFF} xg-py-3d.ok xg-py-3d.pot || exit 1
124
125 exit 0