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