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