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