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.
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
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"));
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.
35 System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out),
37 } catch (UnsupportedEncodingException e) {
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.
46 System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out),
48 } catch (UnsupportedEncodingException e) {
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" }));
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"
73 msgid "'Your
command, please?
', asked the waiter."
77 msgid "a piece of cake"
78 msgid_plural "{0,number} pieces of cake"
83 msgid "{0} is replaced by {1}."
88 ${DIFF} prog.ok prog.pot || exit 1
90 tmpfiles="$tmpfiles fr.po"
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.
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.
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
118 ${DIFF} fr.po fr.po.new || exit 1
120 tmpfiles="$tmpfiles prog_fr.class
"
122 ${MSGFMT} -j -d . -r prog -l fr fr.po || exit 1
124 # Test which of the fr_FR locales are installed.
126 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
127 if test $LOCALE_FR != none; then
128 LC_ALL=$LOCALE_FR ./testlocale
135 if test $LOCALE_FR_UTF8 != none; then
136 LC_ALL=$LOCALE_FR_UTF8 ./testlocale
139 77) LOCALE_FR_UTF8=none;;
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
"
150 «Votre commande, s'il vous plait», dit le garçon.
154 cat <<\EOF > prog.oku
155 «Votre commande, s'il vous plait», dit le garçon.
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