No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / lang-java
blob68ece1976cb9b10a3e3f869e823e99dbb55173f7
1 #! /bin/sh
3 # Test of gettext facilities in the Java language.
4 # Assumes an fr_FR locale is installed.
5 # Assumes the following packages are installed: java.
7 # Note: This test fails when using gcj from GCC 3.1 and GCC 3.2, due to a bug
8 # (libgcj/6576). It is fixed in GCC 3.3.
10 tmpfiles=""
11 trap 'rm -fr $tmpfiles' 1 2 3 15
13 # Test whether we can build and test Java programs.
14 test "${TESTJAVA}" = yes || exit 77
16 tmpfiles="$tmpfiles Program.java"
17 cat <<\EOF > Program.java
18 import java.util.*;
19 import java.io.*;
20 import java.text.*;
21 import gnu.gettext.*;
23 public class Program {
24 public static void main (String[] args) {
25 // Some systems (like Solaris) don't set Locale.getDefault()
26 // as specified by LC_ALL. So set it by hand.
27 Locale.setDefault(new Locale("fr","FR"));
28 EOF
29 case "$host_os" in
30 darwin[56]*)
31 cat <<\EOF >> Program.java
32 // Some systems (like MacOS X) don't set System.out's character encoding
33 // to ISO-8859-1, which is what we need for comparison purposes.
34 try {
35 System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out),
36 true, "ISO-8859-1"));
37 } catch (UnsupportedEncodingException e) {
39 EOF
41 darwin*)
42 cat <<\EOF >> Program.java
43 // Some systems (like MacOS X) don't set System.out's character encoding
44 // to UTF-8, which is what we need for comparison purposes.
45 try {
46 System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out),
47 true, "UTF-8"));
48 } catch (UnsupportedEncodingException e) {
50 EOF
52 esac
53 cat <<\EOF >> Program.java
54 int n = Integer.parseInt(args[0]);
55 ResourceBundle catalog = ResourceBundle.getBundle("prog");
56 System.out.println(GettextResource.gettext(catalog,"'Your command, please?', asked the waiter."));
57 System.out.println(MessageFormat.format(GettextResource.ngettext(catalog,"a piece of cake","{0,number} pieces of cake",n), new Object[] { new Integer(n) }));
58 System.out.println(MessageFormat.format(GettextResource.gettext(catalog,"{0} is replaced by {1}."), new Object[] { "FF", "EUR" }));
61 EOF
63 tmpfiles="$tmpfiles Program.class"
64 : ${JAVACOMP="/bin/sh ../lib/javacomp.sh"}
65 CLASSPATH=../../gettext-runtime/intl-java/libintl.jar ${JAVACOMP} -d . Program.java || exit 1
67 tmpfiles="$tmpfiles prog.pot"
68 : ${XGETTEXT=xgettext}
69 ${XGETTEXT} -o prog.pot --omit-header --no-location Program.java
71 tmpfiles="$tmpfiles prog.ok"
72 cat <<EOF > prog.ok
73 msgid "'Your command, please?', asked the waiter."
74 msgstr ""
76 #, java-format
77 msgid "a piece of cake"
78 msgid_plural "{0,number} pieces of cake"
79 msgstr[0] ""
80 msgstr[1] ""
82 #, java-format
83 msgid "{0} is replaced by {1}."
84 msgstr ""
85 EOF
87 : ${DIFF=diff}
88 ${DIFF} prog.ok prog.pot || exit 1
90 tmpfiles="$tmpfiles fr.po"
91 cat <<\EOF > fr.po
92 msgid ""
93 msgstr ""
94 "Content-Type: text/plain; charset=ISO-8859-1\n"
95 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
97 msgid "'Your command, please?', asked the waiter."
98 msgstr "«Votre commande, s'il vous plait», dit le garçon."
100 # Les gateaux allemands sont les meilleurs du monde.
101 #, java-format
102 msgid "a piece of cake"
103 msgid_plural "{0,number} pieces of cake"
104 msgstr[0] "un morceau de gateau"
105 msgstr[1] "{0,number} morceaux de gateau"
107 # Reverse the arguments.
108 #, java-format
109 msgid "{0} is replaced by {1}."
110 msgstr "{1} remplace {0}."
113 tmpfiles="$tmpfiles fr.po.new"
114 : ${MSGMERGE=msgmerge}
115 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
117 : ${DIFF=diff}
118 ${DIFF} fr.po fr.po.new || exit 1
120 tmpfiles="$tmpfiles prog_fr.class"
121 : ${MSGFMT=msgfmt}
122 ${MSGFMT} -j -d . -r prog -l fr fr.po || exit 1
124 # Test which of the fr_FR locales are installed.
125 : ${LOCALE_FR=fr_FR}
126 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
127 if test $LOCALE_FR != none; then
128 LC_ALL=$LOCALE_FR ./testlocale
129 case $? in
130 0) ;;
131 77) LOCALE_FR=none;;
132 *) exit 1;;
133 esac
135 if test $LOCALE_FR_UTF8 != none; then
136 LC_ALL=$LOCALE_FR_UTF8 ./testlocale
137 case $? in
138 0) ;;
139 77) LOCALE_FR_UTF8=none;;
140 *) exit 1;;
141 esac
143 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
144 rm -fr $tmpfiles; exit 77
147 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
148 : ${DIFF=diff}
149 cat <<\EOF > prog.ok
150 «Votre commande, s'il vous plait», dit le garçon.
151 2 morceaux de gateau
152 EUR remplace FF.
154 cat <<\EOF > prog.oku
155 «Votre commande, s'il vous plait», dit le garçon.
156 2 morceaux de gateau
157 EUR remplace FF.
160 : ${LOCALE_FR=fr_FR}
161 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
162 : ${JAVAEXEC="/bin/sh ../lib/javaexec.sh"}
163 if test $LOCALE_FR != none; then
164 LANGUAGE= LC_ALL=$LOCALE_FR CLASSPATH=.:../../gettext-runtime/intl-java/libintl.jar ${JAVAEXEC} Program 2 > prog.out || exit 1
165 ${DIFF} prog.ok prog.out || exit 1
167 if test $LOCALE_FR_UTF8 != none; then
168 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 CLASSPATH=.:../../gettext-runtime/intl-java/libintl.jar ${JAVAEXEC} Program 2 > prog.out || exit 1
169 ${DIFF} prog.oku prog.out || exit 1
172 rm -fr $tmpfiles
174 exit 0