• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/gettext-0.17/gettext-tools/tests/
1#! /bin/sh
2
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.
6
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.
9
10tmpfiles=""
11trap 'rm -fr $tmpfiles' 1 2 3 15
12
13# Test whether we can build and test Java programs.
14test "${JAVA_CHOICE}" != no || {
15  echo "Skipping test: configured with --disable-java"
16  exit 77
17}
18test "${BUILDJAVA}" = yes || {
19  echo "Skipping test: Java compiler or jar not found"
20  exit 77
21}
22test "${TESTJAVA}" = yes || {
23  echo "Skipping test: Java engine not found"
24  exit 77
25}
26
27tmpfiles="$tmpfiles Program.java"
28cat <<\EOF > Program.java
29import java.util.*;
30import java.io.*;
31import java.text.*;
32import gnu.gettext.*;
33
34public class Program {
35  public static void main (String[] args) {
36    // Some systems (like Solaris) don't set Locale.getDefault()
37    // as specified by LC_ALL. So set it by hand.
38    Locale.setDefault(new Locale("fr","FR"));
39EOF
40case "$host_os" in
41  darwin[56]*)
42cat <<\EOF >> Program.java
43    // Some systems (like MacOS X) don't set System.out's character encoding
44    // to ISO-8859-1, which is what we need for comparison purposes.
45    try {
46      System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out),
47                                    true, "ISO-8859-1"));
48    } catch (UnsupportedEncodingException e) {
49    }
50EOF
51    ;;
52  darwin*)
53cat <<\EOF >> Program.java
54    // Some systems (like MacOS X) don't set System.out's character encoding
55    // to UTF-8, which is what we need for comparison purposes.
56    try {
57      System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out),
58                                    true, "UTF-8"));
59    } catch (UnsupportedEncodingException e) {
60    }
61EOF
62    ;;
63esac
64cat <<\EOF >> Program.java
65    int n = Integer.parseInt(args[0]);
66    ResourceBundle catalog = ResourceBundle.getBundle("prog");
67    System.out.println(GettextResource.gettext(catalog,"'Your command, please?', asked the waiter."));
68    System.out.println(MessageFormat.format(GettextResource.ngettext(catalog,"a piece of cake","{0,number} pieces of cake",n), new Object[] { new Integer(n) }));
69    System.out.println(MessageFormat.format(GettextResource.gettext(catalog,"{0} is replaced by {1}."), new Object[] { "FF", "EUR" }));
70    System.out.println(MessageFormat.format(GettextResource.npgettext(catalog,"++","a piece of cake","{0,number} pieces of cake",n), new Object[] { new Integer(n) }));
71    System.out.println(MessageFormat.format(GettextResource.pgettext(catalog,"++","{0} is replaced by {1}."), new Object[] { "FF", "EUR" }));
72  }
73}
74EOF
75
76tmpfiles="$tmpfiles Program.class prog.err"
77: ${JAVACOMP="/bin/sh ../javacomp.sh"}
78CLASSPATH=../../gettext-runtime/intl-java/libintl.jar ${JAVACOMP} -d . Program.java 2>prog.err \
79  || { cat prog.err 1>&2; exit 1; }
80
81tmpfiles="$tmpfiles prog.tmp prog.pot"
82: ${XGETTEXT=xgettext}
83${XGETTEXT} -o prog.tmp --omit-header --no-location Program.java
84test $? = 0 || { rm -fr $tmpfiles; exit 1; }
85tr -d '\r' < prog.tmp > prog.pot
86test $? = 0 || { rm -fr $tmpfiles; exit 1; }
87
88tmpfiles="$tmpfiles prog.ok"
89cat <<EOF > prog.ok
90msgid "'Your command, please?', asked the waiter."
91msgstr ""
92
93#, java-format
94msgid "a piece of cake"
95msgid_plural "{0,number} pieces of cake"
96msgstr[0] ""
97msgstr[1] ""
98
99#, java-format
100msgid "{0} is replaced by {1}."
101msgstr ""
102
103#, java-format
104msgctxt "++"
105msgid "a piece of cake"
106msgid_plural "{0,number} pieces of cake"
107msgstr[0] ""
108msgstr[1] ""
109
110#, java-format
111msgctxt "++"
112msgid "{0} is replaced by {1}."
113msgstr ""
114EOF
115
116: ${DIFF=diff}
117${DIFF} prog.ok prog.pot || exit 1
118
119tmpfiles="$tmpfiles fr.po"
120cat <<\EOF > fr.po
121msgid ""
122msgstr ""
123"Content-Type: text/plain; charset=ISO-8859-1\n"
124"Plural-Forms: nplurals=2; plural=(n > 1);\n"
125
126msgid "'Your command, please?', asked the waiter."
127msgstr "�Votre commande, s'il vous plait�, dit le garon."
128
129# Les gateaux allemands sont les meilleurs du monde.
130#, java-format
131msgid "a piece of cake"
132msgid_plural "{0,number} pieces of cake"
133msgstr[0] "un morceau de gateau"
134msgstr[1] "{0,number} morceaux de gateau"
135
136# Reverse the arguments.
137#, java-format
138msgid "{0} is replaced by {1}."
139msgstr "{1} remplace {0}."
140
141# Euphemistic formulation.
142#, java-format
143msgctxt "++"
144msgid "a piece of cake"
145msgid_plural "{0,number} pieces of cake"
146msgstr[0] "un morceau de gateau succulent"
147msgstr[1] "{0,number} morceaux de gateau succulent"
148
149# Euphemistic formulation.
150#, java-format
151msgctxt "++"
152msgid "{0} is replaced by {1}."
153msgstr "Le nouveau {1} remplace le vieux {0}."
154EOF
155
156tmpfiles="$tmpfiles fr.po.tmp fr.po.new"
157: ${MSGMERGE=msgmerge}
158${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot
159test $? = 0 || { rm -fr $tmpfiles; exit 1; }
160tr -d '\r' < fr.po.tmp > fr.po.new
161test $? = 0 || { rm -fr $tmpfiles; exit 1; }
162
163: ${DIFF=diff}
164${DIFF} fr.po fr.po.new || exit 1
165
166tmpfiles="$tmpfiles prog_fr.class"
167: ${MSGFMT=msgfmt}
168${MSGFMT} -j -d . -r prog -l fr fr.po || exit 1
169
170# Test which of the fr_FR locales are installed.
171: ${LOCALE_FR=fr_FR}
172: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
173if test $LOCALE_FR != none; then
174  LC_ALL=$LOCALE_FR ./testlocale
175  case $? in
176    0) ;;
177    77) LOCALE_FR=none;;
178    *) exit 1;;
179  esac
180fi
181if test $LOCALE_FR_UTF8 != none; then
182  LC_ALL=$LOCALE_FR_UTF8 ./testlocale
183  case $? in
184    0) ;;
185    77) LOCALE_FR_UTF8=none;;
186    *) exit 1;;
187  esac
188fi
189if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
190  if test -f /usr/bin/localedef; then
191    echo "Skipping test: no french locale is installed"
192  else
193    echo "Skipping test: no french locale is supported"
194  fi
195  rm -fr $tmpfiles; exit 77
196fi
197
198tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
199: ${DIFF=diff}
200cat <<\EOF > prog.ok
201�Votre commande, s'il vous plait�, dit le gar�on.
2022 morceaux de gateau
203EUR remplace FF.
2042 morceaux de gateau succulent
205Le nouveau EUR remplace le vieux FF.
206EOF
207cat <<\EOF > prog.oku
208��Votre commande, s'il vous plait��, dit le gar��on.
2092 morceaux de gateau
210EUR remplace FF.
2112 morceaux de gateau succulent
212Le nouveau EUR remplace le vieux FF.
213EOF
214
215: ${LOCALE_FR=fr_FR}
216: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
217: ${JAVAEXEC="/bin/sh ../javaexec.sh"}
218if test $LOCALE_FR != none; then
219  LANGUAGE= LC_ALL=$LOCALE_FR CLASSPATH=.:../../gettext-runtime/intl-java/libintl.jar ${JAVAEXEC} Program 2 > prog.out || exit 1
220  ${DIFF} prog.ok prog.out || exit 1
221fi
222if test $LOCALE_FR_UTF8 != none; then
223  LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 CLASSPATH=.:../../gettext-runtime/intl-java/libintl.jar ${JAVAEXEC} Program 2 > prog.out || exit 1
224  ${DIFF} prog.oku prog.out || exit 1
225fi
226
227rm -fr $tmpfiles
228
229exit 0
230