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