3 # Test Python support: --from-code option and encoding recognition.
6 trap 'rm -fr $tmpfiles' 1 2 3 15
8 tmpfiles="$tmpfiles xg-py-3a.py"
9 cat <<\EOF > xg-py-3a.py
11 # TRANSLATORS: Fran
\8f«®ois Pinard is a hero.
12 print gettext.gettext("ÆüËܸì");
15 tmpfiles="$tmpfiles xg-py-3b.py"
16 cat <<\EOF > xg-py-3b.py
18 # Hey Emacs! -*- coding: euc-jp -*-
19 # TRANSLATORS: Fran
\8f«®ois Pinard is a hero.
20 print gettext.gettext("ÆüËܸì");
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.
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"
40 "Content-Type: text/plain; charset=UTF-8\n"
41 "Content-Transfer-Encoding: 8bit\n"
43 #. TRANSLATORS: François Pinard is a hero.
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
63 ${DIFF} xg-py-3.ok xg-py-3a.pot
64 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
66 # Verify that if the source file has a magic coding comment, xgettext succeeds.
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
76 ${DIFF} xg-py-3.ok xg-py-3b.pot
77 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
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.
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
90 ${DIFF} xg-py-3.ok xg-py-3c.pot
91 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
93 # Verify that backslashes in and second bytes with value 0x5C are correctly
94 # distinguished in weird encodings like BIG5.
96 tmpfiles="$tmpfiles xg-py-3d.py"
97 cat <<\EOF > xg-py-3d.py
99 # Hey Emacs! -*- coding: big5 -*-
100 print gettext.gettext(u"¬\u0021");
101 print gettext.gettext(u"¬\\u0021");
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
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.
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"
128 "MIME-Version: 1.0\n"
129 "Content-Type: text/plain; charset=UTF-8\n"
130 "Content-Transfer-Encoding: 8bit\n"
141 ${DIFF} xg-py-3d.ok xg-py-3d.pot
142 test $? = 0 || { rm -fr $tmpfiles; exit 1; }