1 1.1 christos #!/bin/sh 2 1.1 christos # 3 1.1 christos # More tests for java support 4 1.1 christos # 5 1.1 christos 6 1.1 christos tmpfiles="" 7 1.1 christos trap 'rm -fr $tmpfiles' 1 2 3 15 8 1.1 christos 9 1.1 christos tmpfiles="$tmpfiles xg-j-2.java" 10 1.1 christos cat <<\EOF > xg-j-2.java 11 1.1 christos class TestCase { 12 1.1 christos public static void main (String[] args) { 13 1.1 christos // Test recognition of \u escapes: Bse Bbchen 14 1.1 christos gettext ("B\u00f6se B\u00fcbchen"); 15 1.1 christos // Test recognition of \u escapes with different number of u 16 1.1 christos gettext ("Japanese: \uu65e5\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu672c\u8A9e"); 17 1.1 christos // Test recognition of \u escapes when they form UTF-16 surrogates 18 1.1 christos // Here: U+1D49E MATHEMATICAL SCRIPT CAPITAL C 19 1.1 christos gettext ("script \ud835\udc9e = ..."); 20 1.1 christos // Test invalid surrogates. 21 1.1 christos gettext ("invalid surrogate \ud835 first half"); 22 1.1 christos gettext ("invalid surrogate \udc9e second half"); 23 1.1 christos // Don't let the line numbers be confused by \u newlines. 24 1.1 christos \u000a \u000d \u000d\u000a 25 1.1 christos gettext ("embedded\nnewline"); 26 1.1 christos // Spaces from end of comment are removed. \u000agettext("dummy"); 27 1.1 christos // Various ways to write a backslash are equivalent. 28 1.1 christos gettext ("\u005c\u005c"); 29 1.1 christos gettext ("\u005c\"); 30 1.1 christos gettext ("\\u005c"); 31 1.1 christos gettext ("\\"); 32 1.1 christos gettext ("\134"); 33 1.1 christos // Escape sequences in strings. 34 1.1 christos gettext ("t -> \t, b -> \b, n -> \n, dquote -> \", squote -> \' ..."); 35 1.1 christos // Octal escapes have 2 or 3 digits, depending on the initial digit. 36 1.1 christos gettext ("bel: \7\nnewline: \12backslash: \134\ndquote-zero: \420\n"); 37 1.1 christos // Hex escapes are not recognized 38 1.1 christos gettext ("no bel: \x07\n"); 39 1.1 christos gettext // Recognized despite comments 40 1.1 christos ( /* Even across multiline 41 1.1 christos comment! */ "this is a single " /* now comes the concatenation! */ + // after + 42 1.1 christos "long line"); 43 1.1 christos // Character literals are not extracted. 44 1.1 christos gettext ('x'); 45 1.1 christos // Invalid concatenations are not concatenated. 46 1.1 christos gettext ("fooba"+'r'); 47 1.1 christos // Verify that the static function name has priority. 48 1.1 christos GettextResource.gettext("NOT extracted", "this one is extracted"); 49 1.1 christos // Verify that a comma inside braces is hidden. 50 1.1 christos GettextResource.gettext( 51 1.1 christos new Object() { 52 1.1 christos public int foo () { 53 1.1 christos return 5, 8; 54 1.1 christos } 55 1.1 christos }, 56 1.1 christos "this is the second argument"); 57 1.1 christos } 58 1.1 christos } 59 1.1 christos EOF 60 1.1 christos 61 1.1 christos tmpfiles="$tmpfiles xg-j-2.tmp xg-j-2.pot" 62 1.1 christos : ${XGETTEXT=xgettext} 63 1.1 christos ${XGETTEXT} --from-code=ISO-8859-1 -c -o xg-j-2.tmp xg-j-2.java 2>/dev/null 64 1.1 christos test $? = 0 || { rm -fr $tmpfiles; exit 1; } 65 1.1 christos grep -v 'POT-Creation-Date' < xg-j-2.tmp > xg-j-2.pot 66 1.1 christos 67 1.1 christos tmpfiles="$tmpfiles xg-j-2.ok" 68 1.1 christos cat <<\EOF > xg-j-2.ok 69 1.1 christos # SOME DESCRIPTIVE TITLE. 70 1.1 christos # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 71 1.1 christos # This file is distributed under the same license as the PACKAGE package. 72 1.1 christos # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. 73 1.1 christos # 74 1.1 christos #, fuzzy 75 1.1 christos msgid "" 76 1.1 christos msgstr "" 77 1.1 christos "Project-Id-Version: PACKAGE VERSION\n" 78 1.1 christos "Report-Msgid-Bugs-To: \n" 79 1.1 christos "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 80 1.1 christos "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 81 1.1 christos "Language-Team: LANGUAGE <LL (at] li.org>\n" 82 1.1 christos "MIME-Version: 1.0\n" 83 1.1 christos "Content-Type: text/plain; charset=UTF-8\n" 84 1.1 christos "Content-Transfer-Encoding: 8bit\n" 85 1.1 christos 86 1.1 christos #. Test recognition of \u escapes: Bse Bbchen 87 1.1 christos #: xg-j-2.java:4 88 1.1 christos msgid "Bse Bbchen" 89 1.1 christos msgstr "" 90 1.1 christos 91 1.1 christos #. Test recognition of \u escapes with different number of u 92 1.1 christos #: xg-j-2.java:6 93 1.1 christos msgid "Japanese: " 94 1.1 christos msgstr "" 95 1.1 christos 96 1.1 christos #. Test recognition of \u escapes when they form UTF-16 surrogates 97 1.1 christos #. Here: U+1D49E MATHEMATICAL SCRIPT CAPITAL C 98 1.1 christos #: xg-j-2.java:9 99 1.1 christos msgid "script = ..." 100 1.1 christos msgstr "" 101 1.1 christos 102 1.1 christos #. Test invalid surrogates. 103 1.1 christos #: xg-j-2.java:11 104 1.1 christos msgid "invalid surrogate first half" 105 1.1 christos msgstr "" 106 1.1 christos 107 1.1 christos #: xg-j-2.java:12 108 1.1 christos msgid "invalid surrogate second half" 109 1.1 christos msgstr "" 110 1.1 christos 111 1.1 christos #. Don't let the line numbers be confused by \u newlines. 112 1.1 christos #: xg-j-2.java:15 113 1.1 christos msgid "" 114 1.1 christos "embedded\n" 115 1.1 christos "newline" 116 1.1 christos msgstr "" 117 1.1 christos 118 1.1 christos #. Spaces from end of comment are removed. 119 1.1 christos #: xg-j-2.java:16 120 1.1 christos msgid "dummy" 121 1.1 christos msgstr "" 122 1.1 christos 123 1.1 christos #. Various ways to write a backslash are equivalent. 124 1.1 christos #: xg-j-2.java:18 xg-j-2.java:19 xg-j-2.java:20 xg-j-2.java:21 xg-j-2.java:22 125 1.1 christos msgid "\\" 126 1.1 christos msgstr "" 127 1.1 christos 128 1.1 christos #. Escape sequences in strings. 129 1.1 christos #: xg-j-2.java:24 130 1.1 christos msgid "" 131 1.1 christos "t -> \t, b -> \b, n -> \n" 132 1.1 christos ", dquote -> \", squote -> ' ..." 133 1.1 christos msgstr "" 134 1.1 christos 135 1.1 christos #. Octal escapes have 2 or 3 digits, depending on the initial digit. 136 1.1 christos #: xg-j-2.java:26 137 1.1 christos msgid "" 138 1.1 christos "bel: \a\n" 139 1.1 christos "newline: \n" 140 1.1 christos "backslash: \\\n" 141 1.1 christos "dquote-zero: \"0\n" 142 1.1 christos msgstr "" 143 1.1 christos 144 1.1 christos #. Hex escapes are not recognized 145 1.1 christos #: xg-j-2.java:28 146 1.1 christos msgid "no bel: \\x07\n" 147 1.1 christos msgstr "" 148 1.1 christos 149 1.1 christos #. Recognized despite comments 150 1.1 christos #. Even across multiline 151 1.1 christos #. comment! 152 1.1 christos #: xg-j-2.java:31 153 1.1 christos msgid "this is a single long line" 154 1.1 christos msgstr "" 155 1.1 christos 156 1.1 christos #. Invalid concatenations are not concatenated. 157 1.1 christos #: xg-j-2.java:36 158 1.1 christos msgid "fooba" 159 1.1 christos msgstr "" 160 1.1 christos 161 1.1 christos #. Verify that the static function name has priority. 162 1.1 christos #: xg-j-2.java:38 163 1.1 christos msgid "this one is extracted" 164 1.1 christos msgstr "" 165 1.1 christos 166 1.1 christos #: xg-j-2.java:46 167 1.1 christos msgid "this is the second argument" 168 1.1 christos msgstr "" 169 1.1 christos EOF 170 1.1 christos 171 1.1 christos : ${DIFF=diff} 172 1.1 christos ${DIFF} xg-j-2.ok xg-j-2.pot 173 1.1 christos result=$? 174 1.1 christos 175 1.1 christos rm -fr $tmpfiles 176 1.1 christos 177 1.1 christos exit $result 178