3 # More tests for java support
7 trap 'rm -fr $tmpfiles' 1 2 3 15
9 tmpfiles="$tmpfiles xg-j-2.java"
10 cat <<\EOF > xg-j-2.java
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");
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
41 comment! */ "this is a single " /* now comes the concatenation! */ + // after +
43 // Character literals are not extracted.
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(
56 "this is the second argument");
61 tmpfiles="$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
64 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
65 # Don't simplify this to "grep ... < xg-j-2.tmp", otherwise OpenBSD 4.0 grep
66 # only outputs "Binary file (standard input) matches".
67 cat xg-j-2.tmp | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > xg-j-2.pot
69 tmpfiles="$tmpfiles xg-j-2.ok"
70 cat <<\EOF > xg-j-2.ok
71 # SOME DESCRIPTIVE TITLE.
72 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
73 # This file is distributed under the same license as the PACKAGE package.
74 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
79 "Project-Id-Version: PACKAGE VERSION\n"
80 "Report-Msgid-Bugs-To: \n"
81 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
82 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
83 "Language-Team: LANGUAGE <LL@li.org>\n"
86 "Content-Type: text/plain; charset=UTF-8\n"
87 "Content-Transfer-Encoding: 8bit\n"
89 #. Test recognition of \u escapes: Böse Bübchen
94 #. Test recognition of \u escapes with different number of u
99 #. Test recognition of \u escapes when they form UTF-16 surrogates
100 #. Here: U+1D49E MATHEMATICAL SCRIPT CAPITAL C
102 msgid "script 𝒞 = ..."
105 #. Test invalid surrogates.
107 msgid "invalid surrogate � first half"
111 msgid "invalid surrogate � second half"
114 #. Don't let the line numbers be confused by \u newlines.
121 #. Spaces from end of comment are removed.
126 #. Various ways to write a backslash are equivalent.
127 #: 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
131 #. Escape sequences in strings.
134 "t -> \t, b -> \b, n -> \n"
135 ", dquote -> \", squote -> ' ..."
138 #. Octal escapes have 2 or 3 digits, depending on the initial digit.
147 #. Hex escapes are not recognized
149 msgid "no bel: \\x07\n"
152 #. Recognized despite comments
153 #. Even across multiline
156 msgid "this is a single long line"
159 #. Invalid concatenations are not concatenated.
164 #. Verify that the static function name has priority.
166 msgid "this one is extracted"
170 msgid "this is the second argument"
175 ${DIFF} xg-j-2.ok xg-j-2.pot