227774c48a90cbc8f876823cb119df610b48d8dc
[platform/upstream/gettext.git] / gettext-tools / tests / xgettext-python-1
1 #!/bin/sh
2
3 # Test of Python support.
4
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
7
8 tmpfiles="$tmpfiles xg-py-1.py"
9 cat <<\EOF > xg-py-1.py
10 # interpret_ansic = true, interpret_unicode = false
11 _("abc\
12 \\def\'ghi\"jkl\a\b\f\n\r\t\v x\040x\x7ey\u0142\U00010123\N{LATIN SMALL LETTER Z}");
13
14 # interpret_ansic = false, interpret_unicode = false
15 _(r"abc\
16 \\def\'ghi\"jkl\a\b\f\n\r\t\v x\040x\x7ey\u0142\U00010123\N{LATIN SMALL LETTER Z}");
17
18 # interpret_ansic = true, interpret_unicode = true
19 _(u"abc\
20 \\def\'ghi\"jkl\a\b\f\n\r\t\v x\040x\x7ey\u0142\U00010123\N{LATIN SMALL LETTER Z}");
21
22 # interpret_ansic = false, interpret_unicode = true
23 _(ur"abc\
24 \\def\'ghi\"jkl\a\b\f\n\r\t\v x\040x\x7ey\u0142\U00010123\N{LATIN SMALL LETTER Z}");
25
26 # This will not be extracted.
27 _(CATEGORIES["default"]["name"]);
28
29 # string concatenation
30 _("abc" "def" + "ghi"
31 "jkl" + mno)
32 EOF
33
34 tmpfiles="$tmpfiles xg-py-1.err xg-py-1.tmp xg-py-1.pot"
35 : ${XGETTEXT=xgettext}
36 ${XGETTEXT} --add-comments --no-location -o xg-py-1.tmp xg-py-1.py 2>xg-py-1.err
37 test $? = 0 || { cat xg-py-1.err; rm -fr $tmpfiles; exit 1; }
38 # Don't simplify this to "grep ... < xg-py-1.tmp", otherwise OpenBSD 4.0 grep
39 # only outputs "Binary file (standard input) matches".
40 cat xg-py-1.tmp | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > xg-py-1.pot
41
42 tmpfiles="$tmpfiles xg-py-1.ok"
43 cat <<\EOF > xg-py-1.ok
44 # SOME DESCRIPTIVE TITLE.
45 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
46 # This file is distributed under the same license as the PACKAGE package.
47 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
48 #
49 #, fuzzy
50 msgid ""
51 msgstr ""
52 "Project-Id-Version: PACKAGE VERSION\n"
53 "Report-Msgid-Bugs-To: \n"
54 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
55 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
56 "Language-Team: LANGUAGE <LL@li.org>\n"
57 "Language: \n"
58 "MIME-Version: 1.0\n"
59 "Content-Type: text/plain; charset=UTF-8\n"
60 "Content-Transfer-Encoding: 8bit\n"
61
62 #. interpret_ansic = true, interpret_unicode = false
63 msgid ""
64 "abc\\def'ghi\"jkl\a\b\f\n"
65 "\r\t\v x x~y\\u0142\\U00010123\\N{LATIN SMALL LETTER Z}"
66 msgstr ""
67
68 #. interpret_ansic = false, interpret_unicode = false
69 msgid ""
70 "abc\\\n"
71 "\\\\def\\'ghi\\\"jkl\\a\\b\\f\\n\\r\\t\\v x\\040x\\x7ey"
72 "\\u0142\\U00010123\\N{LATIN SMALL LETTER Z}"
73 msgstr ""
74
75 #. interpret_ansic = true, interpret_unicode = true
76 msgid ""
77 "abc\\def'ghi\"jkl\a\b\f\n"
78 "\r\t\v x x~ył𐄣z"
79 msgstr ""
80
81 #. interpret_ansic = false, interpret_unicode = true
82 msgid ""
83 "abc\\\n"
84 "\\\\def\\'ghi\\\"jkl\\a\\b\\f\\n\\r\\t\\v x\\040x\\x7eył\\U00010123\\N{LATIN "
85 "SMALL LETTER Z}"
86 msgstr ""
87
88 #. string concatenation
89 msgid "abcdefghijkl"
90 msgstr ""
91 EOF
92
93 : ${DIFF=diff}
94 ${DIFF} xg-py-1.ok xg-py-1.pot
95 result=$?
96
97 rm -fr $tmpfiles
98
99 exit $result