2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
4 # Test of gettext facilities in the Java language.
5 # Assumes an fr_FR locale is installed.
6 # Assumes the following packages are installed: java.
8 # Note: This test fails when using gcj from GCC 3.1 and GCC 3.2, due to a bug
9 # (libgcj/6576). It is fixed in GCC 3.3.
11 # Test whether we can build and test Java programs.
12 test "${JAVA_CHOICE}" != no || {
13 echo "Skipping test: configured with --disable-java"
16 test "${BUILDJAVA}" = yes || {
17 echo "Skipping test: Java compiler or jar not found"
20 test "${TESTJAVA}" = yes || {
21 echo "Skipping test: Java engine not found"
25 cat <<\EOF > Program.java
31 public class Program {
32 public static void main (String[] args) {
33 // Some systems (like Solaris) don't set Locale.getDefault()
34 // as specified by LC_ALL. So set it by hand.
35 Locale.setDefault(new Locale("fr","FR"));
39 cat <<\EOF >> Program.java
40 // Some systems (like MacOS X) don't set System.out's character encoding
41 // according to LC_ALL, which is what we need for comparison purposes.
43 System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out),
45 } catch (UnsupportedEncodingException e) {
50 cat <<\EOF >> Program.java
51 int n = Integer.parseInt(args[0]);
52 ResourceBundle catalog = ResourceBundle.getBundle("prog");
53 System.out.println(GettextResource.gettext(catalog,"'Your command, please?', asked the waiter."));
54 System.out.println(MessageFormat.format(GettextResource.ngettext(catalog,"a piece of cake","{0,number} pieces of cake",n), new Object[] { new Integer(n) }));
55 System.out.println(MessageFormat.format(GettextResource.gettext(catalog,"{0} is replaced by {1}."), new Object[] { "FF", "EUR" }));
56 System.out.println(MessageFormat.format(GettextResource.npgettext(catalog,"++","a piece of cake","{0,number} pieces of cake",n), new Object[] { new Integer(n) }));
57 System.out.println(MessageFormat.format(GettextResource.pgettext(catalog,"++","{0} is replaced by {1}."), new Object[] { "FF", "EUR" }));
62 : ${JAVACOMP="/bin/sh ../../javacomp.sh"}
63 CLASSPATH=../../../gettext-runtime/intl-java/libintl.jar ${JAVACOMP} -d . Program.java 2>prog.err \
64 || { cat prog.err 1>&2; exit 1; }
66 : ${XGETTEXT=xgettext}
67 ${XGETTEXT} -o prog.tmp --omit-header --no-location Program.java || exit 1
68 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || exit 1
71 msgid "'Your command, please?', asked the waiter."
75 msgid "a piece of cake"
76 msgid_plural "{0,number} pieces of cake"
81 msgid "{0} is replaced by {1}."
86 msgid "a piece of cake"
87 msgid_plural "{0,number} pieces of cake"
93 msgid "{0} is replaced by {1}."
98 ${DIFF} prog.ok prog.pot || exit 1
103 "Content-Type: text/plain; charset=ISO-8859-1\n"
104 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
106 msgid "'Your command, please?', asked the waiter."
107 msgstr "«Votre commande, s'il vous plait», dit le garçon."
109 # Les gateaux allemands sont les meilleurs du monde.
111 msgid "a piece of cake"
112 msgid_plural "{0,number} pieces of cake"
113 msgstr[0] "un morceau de gateau"
114 msgstr[1] "{0,number} morceaux de gateau"
116 # Reverse the arguments.
118 msgid "{0} is replaced by {1}."
119 msgstr "{1} remplace {0}."
121 # Euphemistic formulation.
124 msgid "a piece of cake"
125 msgid_plural "{0,number} pieces of cake"
126 msgstr[0] "un morceau de gateau succulent"
127 msgstr[1] "{0,number} morceaux de gateau succulent"
129 # Euphemistic formulation.
132 msgid "{0} is replaced by {1}."
133 msgstr "Le nouveau {1} remplace le vieux {0}."
136 : ${MSGMERGE=msgmerge}
137 ${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot || exit 1
138 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new || exit 1
141 ${DIFF} fr.po fr.po.new || exit 1
144 ${MSGFMT} -j -d . -r prog -l fr fr.po || exit 1
146 # Test which of the fr_FR locales are installed.
148 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
149 if test $LOCALE_FR != none; then
150 LC_ALL=$LOCALE_FR ../testlocale
157 if test $LOCALE_FR_UTF8 != none; then
158 LC_ALL=$LOCALE_FR_UTF8 ../testlocale
161 77) LOCALE_FR_UTF8=none;;
165 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
166 if test -f /usr/bin/localedef; then
167 echo "Skipping test: no french locale is installed"
169 echo "Skipping test: no french locale is supported"
176 «Votre commande, s'il vous plait», dit le garçon.
179 2 morceaux de gateau succulent
180 Le nouveau EUR remplace le vieux FF.
182 cat <<\EOF > prog.oku
183 «Votre commande, s'il vous plait», dit le garçon.
186 2 morceaux de gateau succulent
187 Le nouveau EUR remplace le vieux FF.
191 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
192 : ${JAVAEXEC="/bin/sh ../../javaexec.sh"}
193 if test $LOCALE_FR != none; then
194 prepare_locale_ fr $LOCALE_FR
195 LANGUAGE= LC_ALL=$LOCALE_FR CLASSPATH=.:../../../gettext-runtime/intl-java/libintl.jar ${JAVAEXEC} Program 2 ISO-8859-1 > prog.out || exit 1
196 ${DIFF} prog.ok prog.out || exit 1
198 if test $LOCALE_FR_UTF8 != none; then
199 prepare_locale_ fr $LOCALE_FR_UTF8
200 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 CLASSPATH=.:../../../gettext-runtime/intl-java/libintl.jar ${JAVAEXEC} Program 2 UTF-8 > prog.out || exit 1
201 ${DIFF} prog.oku prog.out || exit 1