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