summaryrefslogtreecommitdiffstats
path: root/gettext-tools/tests/xgettext-java-2
blob: 2287ff4263dbcd42c1bb718b1912784d0c113ab2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/bin/sh
#
# More tests for java support
#

tmpfiles=""
trap 'rm -fr $tmpfiles' 1 2 3 15

tmpfiles="$tmpfiles xg-j-2.java"
cat <<\EOF > xg-j-2.java
class TestCase {
  public static void main (String[] args) {
    // Test recognition of \u escapes: Bse Bbchen
    gettext ("B\u00f6se B\u00fcbchen");
    // Test recognition of \u escapes with different number of u
    gettext ("Japanese: \uu65e5\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu672c\u8A9e");
    // Test recognition of \u escapes when they form UTF-16 surrogates
    // Here: U+1D49E MATHEMATICAL SCRIPT CAPITAL C
    gettext ("script \ud835\udc9e = ...");
    // Test invalid surrogates.
    gettext ("invalid surrogate \ud835 first half");
    gettext ("invalid surrogate \udc9e second half");
    // Don't let the line numbers be confused by \u newlines.
    \u000a \u000d \u000d\u000a
    gettext ("embedded\nnewline");
    // Spaces from end of comment are removed.    \u000agettext("dummy");
    // Various ways to write a backslash are equivalent.
    gettext ("\u005c\u005c");
    gettext ("\u005c\");
    gettext ("\\u005c");
    gettext ("\\");
    gettext ("\134");
    // Escape sequences in strings.
    gettext ("t -> \t, b -> \b, n -> \n, dquote -> \", squote -> \' ...");
    // Octal escapes have 2 or 3 digits, depending on the initial digit.
    gettext ("bel: \7\nnewline: \12backslash: \134\ndquote-zero: \420\n");
    // Hex escapes are not recognized
    gettext ("no bel: \x07\n");
    gettext // Recognized despite comments
       ( /* Even across multiline
comment! */ "this is a single " /* now comes the concatenation! */ + // after +
         "long line");
    // Character literals are not extracted.
    gettext ('x');
    // Invalid concatenations are not concatenated.
    gettext ("fooba"+'r');
    // Verify that the static function name has priority.
    GettextResource.gettext("NOT extracted", "this one is extracted");
    // Verify that a comma inside braces is hidden.
    GettextResource.gettext(
        new Object() {
          public int foo () {
            return 5, 8;
          }
        },
        "this is the second argument");
  }
}
EOF

tmpfiles="$tmpfiles xg-j-2.tmp xg-j-2.pot"
: ${XGETTEXT=xgettext}
${XGETTEXT} --from-code=ISO-8859-1 -c -o xg-j-2.tmp xg-j-2.java 2>/dev/null
test $? = 0 || { rm -fr $tmpfiles; exit 1; }
grep -v 'POT-Creation-Date' < xg-j-2.tmp > xg-j-2.pot

tmpfiles="$tmpfiles xg-j-2.ok"
cat <<\EOF > xg-j-2.ok
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#. Test recognition of \u escapes: Böse Bübchen
#: xg-j-2.java:4
msgid "Böse Bübchen"
msgstr ""

#. Test recognition of \u escapes with different number of u
#: xg-j-2.java:6
msgid "Japanese: 日本語"
msgstr ""

#. Test recognition of \u escapes when they form UTF-16 surrogates
#. Here: U+1D49E MATHEMATICAL SCRIPT CAPITAL C
#: xg-j-2.java:9
msgid "script 𝒞 = ..."
msgstr ""

#. Test invalid surrogates.
#: xg-j-2.java:11
msgid "invalid surrogate � first half"
msgstr ""

#: xg-j-2.java:12
msgid "invalid surrogate  second half"
msgstr ""

#. Don't let the line numbers be confused by \u newlines.
#: xg-j-2.java:15
msgid ""
"embedded\n"
"newline"
msgstr ""

#. Spaces from end of comment are removed.
#: xg-j-2.java:16
msgid "dummy"
msgstr ""

#. Various ways to write a backslash are equivalent.
#: 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
msgid "\\"
msgstr ""

#. Escape sequences in strings.
#: xg-j-2.java:24
msgid ""
"t -> \t, b -> \b, n -> \n"
", dquote -> \", squote -> ' ..."
msgstr ""

#. Octal escapes have 2 or 3 digits, depending on the initial digit.
#: xg-j-2.java:26
msgid ""
"bel: \n"
"newline: \n"
"backslash: \\\n"
"dquote-zero: \"0\n"
msgstr ""

#. Hex escapes are not recognized
#: xg-j-2.java:28
msgid "no bel: \\x07\n"
msgstr ""

#. Recognized despite comments
#. Even across multiline
#. comment!
#: xg-j-2.java:31
msgid "this is a single long line"
msgstr ""

#. Invalid concatenations are not concatenated.
#: xg-j-2.java:36
msgid "fooba"
msgstr ""

#. Verify that the static function name has priority.
#: xg-j-2.java:38
msgid "this one is extracted"
msgstr ""

#: xg-j-2.java:46
msgid "this is the second argument"
msgstr ""
EOF

: ${DIFF=diff}
${DIFF} xg-j-2.ok xg-j-2.pot
result=$?

rm -fr $tmpfiles

exit $result