]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
New example for Qt/Jambi.
authorBruno Haible <bruno@clisp.org>
Sat, 20 Oct 2007 22:07:12 +0000 (22:07 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:15:21 +0000 (12:15 +0200)
18 files changed:
NEWS
gettext-tools/doc/ChangeLog
gettext-tools/doc/gettext.texi
gettext-tools/examples/ChangeLog
gettext-tools/examples/Makefile.am
gettext-tools/examples/README
gettext-tools/examples/hello-java-qtjambi/BUGS [new file with mode: 0644]
gettext-tools/examples/hello-java-qtjambi/Hello.java [new file with mode: 0644]
gettext-tools/examples/hello-java-qtjambi/INSTALL [new file with mode: 0644]
gettext-tools/examples/hello-java-qtjambi/Makefile.am [new file with mode: 0644]
gettext-tools/examples/hello-java-qtjambi/autoclean.sh [new file with mode: 0755]
gettext-tools/examples/hello-java-qtjambi/autogen.sh [new file with mode: 0755]
gettext-tools/examples/hello-java-qtjambi/configure.ac [new file with mode: 0644]
gettext-tools/examples/hello-java-qtjambi/m4/Makefile.am [new file with mode: 0644]
gettext-tools/examples/hello-java-qtjambi/m4/Test15.class [new file with mode: 0644]
gettext-tools/examples/hello-java-qtjambi/m4/Test15.java [new file with mode: 0644]
gettext-tools/examples/hello-java-qtjambi/po/Makefile.am [new file with mode: 0644]
gettext-tools/examples/po/Makefile.am

diff --git a/NEWS b/NEWS
index 33d427cb77cf8500cf4730b0376ce0db82b9104c..2820eec1d3025b9d3247ce690b48b0412665eaaf 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -22,7 +22,9 @@ Version 0.16.2 - January 2007
     of KDE 4 format strings.
 
 * Documentation:
-  The "Users" chapter has been completely rewritten.
+  - The "Users" chapter has been completely rewritten.
+  - A complete example showing the use of GNU gettext in Java with the Qt/Jambi
+    GUI toolkit has been added.
 \f
 Version 0.16.1 - November 2006
 
index aa953381e365296e1b50675fa6ddc39319ccbd0c..ac2e7cced0b8e1327dce80b74d77dca3107316ae 100644 (file)
@@ -1,3 +1,7 @@
+2007-10-20  Bruno Haible  <bruno@clisp.org>
+
+       * gettext.texi (Java): Mention the hello-java-qtjambi example.
+
 2007-10-05  Bruno Haible  <bruno@clisp.org>
 
        * gettext.texi: Enforce normal indentation of the first paragraph of each
index 1ec62526670f9e9478c503fea5674e641857ff62..5637435ea4b74898e792a454f5ef6eaf0e4aa63d 100644 (file)
@@ -9765,8 +9765,9 @@ To use this API, one needs the @code{libintl.jar} file which is part of
 the GNU gettext package and distributed under the LGPL.
 @end enumerate
 
-Three examples, using the second API, are available in the @file{examples}
-directory: @code{hello-java}, @code{hello-java-awt}, @code{hello-java-swing}.
+Four examples, using the second API, are available in the @file{examples}
+directory: @code{hello-java}, @code{hello-java-awt}, @code{hello-java-swing},
+@code{hello-java-qtjambi}.
 
 Now, to make use of the API and define a shorthand for @samp{getString},
 there are three idioms that you can choose from:
index 37c222775b8540a2a21eac17f02c12c33e7fbeac..d96d8a40a5b8f39d65064172df1ef91ace494e73 100644 (file)
@@ -1,3 +1,16 @@
+2007-10-20  Bruno Haible  <bruno@clisp.org>
+
+       New example for Qt/Jambi.
+       * hello-java-qtjambi: New subdirectory.
+       * README: Mention it.
+       * Makefile.am (EXAMPLESFILES): Add the files in hello-java-qtjambi.
+       (EXAMPLESDIRS): Add hello-java-qtjambi.
+       * po/Makefile.am (POTFILES): Add hello-java-qtjambi source.
+       (SMALLPOTS): Add hello-java-qtjambi.pot.
+       (hello-java-qtjambi.pot): New rule.
+       (SMALLPOFILES_FOR_lang): Add hello-java-qtjambi elements.
+       (../hello-java-qtjambi/po/$(LL).po): New rule.
+
 2007-10-18  Bruno Haible  <bruno@clisp.org>
 
        * hello-*/po/Makefile.am ($(DOMAIN).pot-update): Don't pass the package
index 9bf7a26bdf52ff8c2892508cdfd4b6fe90b0bba4..9c68a69ac9f5c5bcc24d73adec37aeb972697846 100644 (file)
@@ -258,6 +258,18 @@ EXAMPLESFILES = \
   hello-java-swing/m4/TestAWT.class \
   hello-java-swing/po/Makefile.am \
   \
+  hello-java-qtjambi/INSTALL \
+  hello-java-qtjambi/BUGS \
+  hello-java-qtjambi/autogen.sh \
+  hello-java-qtjambi/autoclean.sh \
+  hello-java-qtjambi/Hello.java \
+  hello-java-qtjambi/Makefile.am \
+  hello-java-qtjambi/configure.ac \
+  hello-java-qtjambi/m4/Makefile.am \
+  hello-java-qtjambi/m4/Test15.java \
+  hello-java-qtjambi/m4/Test15.class \
+  hello-java-qtjambi/po/Makefile.am \
+  \
   hello-csharp/INSTALL \
   hello-csharp/autogen.sh \
   hello-csharp/autoclean.sh \
@@ -367,6 +379,7 @@ EXAMPLESDIRS = \
   hello-java \
   hello-java-awt \
   hello-java-swing \
+  hello-java-qtjambi \
   hello-csharp \
   hello-csharp-forms \
   hello-gawk \
index 9945d7940918e022ababcefd77c9cacd799c942b..b57664b0478010e2afcef17232d70ac2a14c224e 100644 (file)
@@ -24,6 +24,7 @@ environment.
     hello-java                 Java
     hello-java-awt             Java              AWT
     hello-java-swing           Java              Swing
+    hello-java-qtjambi         Java              Qt
     hello-csharp               C#
     hello-csharp-forms         C#                Forms
     hello-gawk                 awk
diff --git a/gettext-tools/examples/hello-java-qtjambi/BUGS b/gettext-tools/examples/hello-java-qtjambi/BUGS
new file mode 100644 (file)
index 0000000..c0053e9
--- /dev/null
@@ -0,0 +1,2 @@
+Qt looks only at the LANG and LC_ALL values and ignores LC_MESSAGES if LC_ALL is unset.
+Therefore, to make it work, you have to set LC_ALL to the same value as LC_MESSAGES.
diff --git a/gettext-tools/examples/hello-java-qtjambi/Hello.java b/gettext-tools/examples/hello-java-qtjambi/Hello.java
new file mode 100644 (file)
index 0000000..9fc8baa
--- /dev/null
@@ -0,0 +1,73 @@
+// Example for use of GNU gettext.
+// This file is in the public domain.
+//
+// Source code of the Java/QtJambi program.
+
+import java.util.*;
+import java.io.*;
+import java.text.*;
+import com.trolltech.qt.core.*;
+import com.trolltech.qt.gui.*;
+import gnu.gettext.*;
+
+public class Hello {
+  public static void main (String[] args) {
+    ResourceBundle catalog = ResourceBundle.getBundle("hello-java-qtjambi");
+
+    QApplication.initialize(args);
+
+    QMainWindow window = new QMainWindow();
+    window.setWindowTitle("Hello example");
+
+    QWidget panel = new QWidget();
+    QVBoxLayout panelLayout = new QVBoxLayout();
+    panelLayout.setSpacing(2);
+
+    QLabel label1 =
+      new QLabel(GettextResource.gettext(catalog,"Hello, world!"));
+    panelLayout.addWidget(label1);
+
+    QLabel label2 =
+      new QLabel(
+          MessageFormat.format(
+              GettextResource.gettext(catalog,
+                  "This program is running as process number {0}."),
+              new Object[] { getPid() }));
+    panelLayout.addWidget(label2);
+
+    QWidget buttonBar = new QWidget();
+    QHBoxLayout buttonBarLayout = new QHBoxLayout();
+    QWidget filler = new QWidget(); // makes the button right-aligned
+    buttonBarLayout.addWidget(filler);
+    QPushButton button = new QPushButton("OK");
+    button.setMaximumWidth(button.sizeHint().width()+20);
+    button.clicked.connect(window, "close()");
+    buttonBarLayout.addWidget(button);
+    buttonBar.setLayout(buttonBarLayout);
+    panelLayout.addWidget(buttonBar);
+
+    panel.setLayout(panelLayout);
+
+    window.setCentralWidget(panel);
+
+    window.show();
+
+    QApplication.exec();
+  }
+
+  /* Return the process ID of the current process.  */
+  private static String getPid () {
+    try {
+      String[] args = new String[] { "/bin/sh", "-c", "echo $PPID" };
+      Process p = Runtime.getRuntime().exec(args);
+      InputStream p_out = p.getInputStream();
+      String s = (new BufferedReader(new InputStreamReader(p_out))).readLine();
+      p.destroy();
+      if (s != null)
+        return s;
+    } catch (IOException e) {
+      e.printStackTrace();
+    }
+    return "???";
+  }
+}
diff --git a/gettext-tools/examples/hello-java-qtjambi/INSTALL b/gettext-tools/examples/hello-java-qtjambi/INSTALL
new file mode 100644 (file)
index 0000000..fd166ed
--- /dev/null
@@ -0,0 +1,17 @@
+This example relies on:
+  - a recent Java implementation
+    (i.e. when using Sun's JDK: at least JDK 1.5)
+  - the Qt4/Java binding (libqtjambi)
+  - Qt4 (libQtGui, libQtCore) and its dependencies: libpng, zlib (libz)
+  - the C++ runtime libraries (libstdc++)
+
+Installation:
+  ./autogen.sh
+  export LD_LIBRARY_PATH=<directory with libqtjambi and libQt*.so.4>
+  export CLASSPATH=.:.../qtjambi.jar:.../libintl.jar
+  ./configure --prefix=/some/prefix
+  make
+  make install
+Cleanup:
+  make distclean
+  ./autoclean.sh
diff --git a/gettext-tools/examples/hello-java-qtjambi/Makefile.am b/gettext-tools/examples/hello-java-qtjambi/Makefile.am
new file mode 100644 (file)
index 0000000..9c80241
--- /dev/null
@@ -0,0 +1,165 @@
+# Example for use of GNU gettext.
+# This file is in the public domain.
+#
+# Makefile configuration - processed by automake.
+
+# General automake options.
+AUTOMAKE_OPTIONS = foreign
+ACLOCAL_AMFLAGS = -I m4
+
+# The list of subdirectories containing Makefiles.
+SUBDIRS = m4 po
+
+# The list of programs that are built.
+bin_JAVAPROGRAMS = hello
+
+# The source files of the 'hello' program.
+hello_SOURCES = Hello.java
+hello_CLASSES = Hello.class
+
+# The entry point of the 'hello' program.
+hello_MAINCLASS = Hello
+
+# The link dependencies of the 'hello' program.
+hello_JAVALIBS = @LIBINTL_JAR@
+
+# The resources of the 'hello' program, excluding message catalogs, but
+# including the fallback message catalog.
+hello_RESOURCES = hello-java-qtjambi.properties
+
+# Resources that are generated from PO files.
+MAINTAINERCLEANFILES = hello-java-qtjambi*.properties
+
+# Additional files to be distributed.
+EXTRA_DIST = autogen.sh autoclean.sh
+
+
+# ----------------- General rules for compiling Java programs -----------------
+
+jardir = $(datadir)/$(PACKAGE)
+pkgdatadir = $(datadir)/$(PACKAGE)
+pkglibdir = $(libdir)/$(PACKAGE)
+
+GCJ = @GCJ@
+GCJFLAGS = @GCJFLAGS@
+JAR = @JAR@
+JAVACOMP = $(SHELL) javacomp.sh
+AR = ar
+RANLIB = @RANLIB@
+
+EXTRA_DIST += $(hello_SOURCES)
+CLEANFILES =
+DISTCLEANFILES = javacomp.sh javaexec.sh
+
+
+if USEJEXE
+
+
+# Rules for compiling Java programs as native code.
+
+all-local: $(hello_MAINCLASS)$(EXEEXT) hello-resources.jar hello.sh
+
+# Does not work yet with GCC 3.3.
+#$(hello_MAINCLASS)$(EXEEXT): $(srcdir)/Hello.java
+#      CLASSPATH=.@CLASSPATH_SEPARATOR@$(hello_JAVALIBS)@CLASSPATH_SEPARATOR@$$CLASSPATH $(GCJ) $(GCJFLAGS) $(srcdir)/Hello.java $(hello_JAVALIBS) --main=$(hello_MAINCLASS) -o $@
+
+$(hello_MAINCLASS)$(EXEEXT): Hello.$(OBJEXT) libintl.a
+       $(GCJ) $(GCJFLAGS) Hello.$(OBJEXT) libintl.a --main=$(hello_MAINCLASS) -o $@
+
+Hello.$(OBJEXT): $(srcdir)/Hello.java
+       CLASSPATH=.@CLASSPATH_SEPARATOR@$(hello_JAVALIBS)@CLASSPATH_SEPARATOR@$$CLASSPATH $(GCJ) $(GCJFLAGS) -c $(srcdir)/Hello.java -o $@
+
+libintl.a:
+       rm -rf tmpdir
+       mkdir tmpdir
+       cd tmpdir && $(JAR) xf @LIBINTL_JAR@ && \
+       for f in `find . -name '*.class' -print`; do \
+         $(GCJ) $(GCJFLAGS) -c $$f -o `echo $$f | sed -e 's,^\./,,' -e 's,\.class$$,,' -e 's,/,.,g'`.$(OBJEXT) || exit 1; \
+       done && \
+       rm -f ../libintl.a && \
+       ar cru ../libintl.a `find . -name '*.$(OBJEXT)' -print`
+       rm -rf tmpdir
+       $(RANLIB) $@
+
+hello-resources.jar:
+       catalogs=`MAKEFLAGS= $(MAKE) -s -C po echo-catalogs`; \
+       $(JAR) cf $@ $(hello_RESOURCES) $$catalogs
+
+hello.sh:
+       { echo '#!/bin/sh'; \
+         echo "CLASSPATH='$(jardir)/hello-resources.jar'\$${CLASSPATH+\"@CLASSPATH_SEPARATOR@\$$CLASSPATH\"}"; \
+         echo "export CLASSPATH"; \
+         echo "exec '$(pkglibdir)/$(hello_MAINCLASS)$(EXEEXT)' \"\$$@\""; \
+       } > $@
+
+install-exec-local: all-local
+       $(mkdir_p) $(DESTDIR)$(bindir)
+       $(INSTALL_SCRIPT) hello.sh $(DESTDIR)$(bindir)/hello
+       $(mkdir_p) $(DESTDIR)$(pkglibdir)
+       $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $(hello_MAINCLASS)$(EXEEXT) $(DESTDIR)$(pkglibdir)/$(hello_MAINCLASS)$(EXEEXT)
+
+install-data-local: all-local
+       $(mkdir_p) $(DESTDIR)$(jardir)
+       $(INSTALL_DATA) hello-resources.jar $(DESTDIR)$(jardir)/hello-resources.jar
+
+installdirs-local:
+       $(mkdir_p) $(DESTDIR)$(bindir)
+       $(mkdir_p) $(DESTDIR)$(pkglibdir)
+       $(mkdir_p) $(DESTDIR)$(jardir)
+
+uninstall-local:
+       rm -f $(DESTDIR)$(bindir)/hello
+       rm -f $(DESTDIR)$(pkglibdir)/$(hello_MAINCLASS)$(EXEEXT)
+       rm -f $(DESTDIR)$(jardir)/hello-resources.jar
+
+CLEANFILES += $(hello_MAINCLASS)$(EXEEXT) *.$(OBJEXT) *.a tmpdir hello-resources.jar hello.sh
+
+
+else
+
+
+# Rules for compiling Java programs as jar libraries.
+# This is the preferred mode during development, because you can easily test
+# the program without installing it, simply by doing "java -jar hello.jar".
+
+all-local: hello.jar hello.sh
+
+hello.jar: $(hello_CLASSES)
+       { echo "Manifest-Version: 1.0"; echo "Main-Class: $(hello_MAINCLASS)"; echo 'Class-Path: @LIBINTL_JAR@'; } > Manifest.mf
+       catalogs=`MAKEFLAGS= $(MAKE) -s -C po echo-catalogs`; \
+       $(JAR) cfm $@ Manifest.mf Hello*.class $(hello_RESOURCES) $$catalogs
+       rm -f Manifest.mf
+
+Hello.class: $(srcdir)/Hello.java
+       CLASSPATH=.@CLASSPATH_SEPARATOR@$(hello_JAVALIBS)@CLASSPATH_SEPARATOR@$$CLASSPATH $(JAVACOMP) -d . $(srcdir)/Hello.java
+
+hello.sh:
+       { echo '#!/bin/sh'; \
+         echo "CLASSPATH='$(jardir)/hello.jar@CLASSPATH_SEPARATOR@$(hello_JAVALIBS)'\$${CLASSPATH+\"@CLASSPATH_SEPARATOR@\$$CLASSPATH\"}"; \
+         echo "export CLASSPATH"; \
+         echo "exec /bin/sh '$(pkgdatadir)/javaexec.sh' $(hello_MAINCLASS) \"\$$@\""; \
+       } > $@
+
+install-exec-local: all-local
+       $(mkdir_p) $(DESTDIR)$(bindir)
+       $(INSTALL_SCRIPT) hello.sh $(DESTDIR)$(bindir)/hello
+
+install-data-local: all-local
+       $(mkdir_p) $(DESTDIR)$(jardir)
+       $(INSTALL_DATA) hello.jar $(DESTDIR)$(jardir)/hello.jar
+       $(mkdir_p) $(DESTDIR)$(pkgdatadir)
+       $(INSTALL_DATA) javaexec.sh $(DESTDIR)$(pkgdatadir)/javaexec.sh
+
+installdirs-local:
+       $(mkdir_p) $(DESTDIR)$(jardir)
+       $(mkdir_p) $(DESTDIR)$(pkgdatadir)
+
+uninstall-local:
+       rm -f $(DESTDIR)$(bindir)/hello
+       rm -f $(DESTDIR)$(jardir)/hello.jar
+       rm -f $(DESTDIR)$(pkgdatadir)/javaexec.sh
+
+CLEANFILES += hello.jar Hello*.class Manifest.mf hello.sh
+
+
+endif
diff --git a/gettext-tools/examples/hello-java-qtjambi/autoclean.sh b/gettext-tools/examples/hello-java-qtjambi/autoclean.sh
new file mode 100755 (executable)
index 0000000..66ba430
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Example for use of GNU gettext.
+# This file is in the public domain.
+#
+# Script for cleaning all autogenerated files.
+
+test ! -f Makefile || make distclean
+
+# Brought in by explicit copy.
+rm -f m4/nls.m4
+rm -f m4/po.m4
+rm -f m4/progtest.m4
+rm -f po/remove-potcdate.sin
+
+# Brought in by explicit copy.
+rm -f m4/gcj.m4
+rm -f m4/javacomp.m4
+rm -f m4/javaexec.m4
+rm -f javacomp.sh.in
+rm -f javaexec.sh.in
+
+# Generated by aclocal.
+rm -f aclocal.m4
+
+# Generated by autoconf.
+rm -f configure
+
+# Generated or brought in by automake.
+rm -f Makefile.in
+rm -f m4/Makefile.in
+rm -f po/Makefile.in
+rm -f install-sh
+rm -f missing
+rm -f po/*.pot
+rm -f po/stamp-po
+rm -f hello-java-qtjambi*.properties
diff --git a/gettext-tools/examples/hello-java-qtjambi/autogen.sh b/gettext-tools/examples/hello-java-qtjambi/autogen.sh
new file mode 100755 (executable)
index 0000000..8568350
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/sh
+# Example for use of GNU gettext.
+# This file is in the public domain.
+#
+# Script for regenerating all autogenerated files.
+
+if test -r ../Makefile.am; then
+  # Inside the gettext source directory.
+  GETTEXT_TOPSRCDIR=../../..
+else
+  if test -r ../Makefile; then
+    # Inside a gettext build directory.
+    GETTEXT_TOOLS_SRCDIR=`sed -n -e 's,^top_srcdir *= *\(.*\)$,\1,p' ../Makefile`
+    # Adjust a relative top_srcdir.
+    case $GETTEXT_TOOLS_SRCDIR in
+      /*) ;;
+      *) GETTEXT_TOOLS_SRCDIR=../$GETTEXT_TOOLS_SRCDIR ;;
+    esac
+    GETTEXT_TOPSRCDIR=$GETTEXT_TOOLS_SRCDIR/../..
+  else
+    # Installed under ${prefix}/share/doc/gettext/examples.
+    . ../installpaths
+  fi
+fi
+
+cp -p ${ACLOCALDIR-$GETTEXT_TOPSRCDIR/gettext-runtime/m4}/nls.m4 m4/nls.m4
+cp -p ${ACLOCALDIR-$GETTEXT_TOPSRCDIR/gettext-runtime/m4}/po.m4 m4/po.m4
+cp -p ${ACLOCALDIR-$GETTEXT_TOPSRCDIR/gettext-runtime/m4}/progtest.m4 m4/progtest.m4
+cp -p ${GETTEXTSRCPODIR-$GETTEXT_TOPSRCDIR/gettext-runtime/po}/remove-potcdate.sin po/remove-potcdate.sin
+
+cp -p ${EXAMPLESCONFIGDIR-$GETTEXT_TOPSRCDIR/gettext-tools/gnulib-m4}/gcj.m4 m4/gcj.m4
+cp -p ${EXAMPLESCONFIGDIR-$GETTEXT_TOPSRCDIR/gettext-tools/gnulib-m4}/javacomp.m4 m4/javacomp.m4
+cp -p ${EXAMPLESCONFIGDIR-$GETTEXT_TOPSRCDIR/gettext-tools/gnulib-m4}/javaexec.m4 m4/javaexec.m4
+cp -p ${EXAMPLESCONFIGDIR-$GETTEXT_TOPSRCDIR/build-aux}/javacomp.sh.in javacomp.sh.in
+cp -p ${EXAMPLESCONFIGDIR-$GETTEXT_TOPSRCDIR/build-aux}/javaexec.sh.in javaexec.sh.in
+
+aclocal -I m4
+
+autoconf
+
+automake -a -c
+
+./configure
+cd po
+make update-po
+cd ..
+make distclean
diff --git a/gettext-tools/examples/hello-java-qtjambi/configure.ac b/gettext-tools/examples/hello-java-qtjambi/configure.ac
new file mode 100644 (file)
index 0000000..f62d652
--- /dev/null
@@ -0,0 +1,69 @@
+dnl Example for use of GNU gettext.
+dnl This file is in the public domain.
+dnl
+dnl Configuration file - processed by autoconf.
+
+AC_INIT
+AC_CONFIG_SRCDIR(Hello.java)
+AM_INIT_AUTOMAKE(hello-java-qtjambi, 0)
+
+dnl Check whether we can build native executable.
+dnl This does currently not work, since QtJambi requires a Java >= 1.5.
+dnl AC_ARG_ENABLE(java-exe,
+dnl   [  --enable-java-exe       compile Java to native code, not to bytecode],
+dnl   :, enable_java_exe=no)
+dnl gt_GCJ
+dnl if test "$enable_java_exe" != no && test -n "$HAVE_GCJ"; then
+dnl   BUILDJAVAEXE=yes
+dnl else
+dnl   BUILDJAVAEXE=no
+dnl fi
+BUILDJAVAEXE=no
+AC_SUBST(BUILDJAVAEXE)
+AM_CONDITIONAL([USEJEXE], [test $BUILDJAVAEXE = yes])
+AC_PROG_RANLIB
+
+dnl Check whether we can execute Java programs.
+gt_JAVAEXEC([Test15], [$srcdir/m4])
+dnl Check whether we can build Java programs.
+gt_JAVACOMP([1.5], [1.5])
+AC_CHECK_PROG(JAR, jar, jar)
+if test -n "$HAVE_JAVACOMP" && test -n "$JAR"; then
+  BUILDJAVA=yes
+else
+  BUILDJAVA=no
+fi
+AC_SUBST(BUILDJAVA)
+if test -n "$HAVE_JAVAEXEC" && test $BUILDJAVA = yes; then
+  TESTJAVA=yes
+else
+  TESTJAVA=no
+fi
+AC_SUBST(TESTJAVA)
+
+dnl Checks for compiler output filename suffixes.
+AC_OBJEXT
+AC_EXEEXT
+
+dnl Checks for needed libraries.
+AM_PATH_PROG_WITH_TEST([GETTEXT_WITH_LIBINTL_JAR], [gettext],
+  [{ basedir=`echo "$ac_dir" | sed -e 's,/bin$,,'`; test -r "$basedir"/share/gettext/libintl.jar; }])
+if test -z "$GETTEXT_WITH_LIBINTL_JAR"; then
+  echo "Required library libintl.jar not found." 1>&2
+  exit 1
+fi
+changequote(,)dnl
+basedir=`echo "$GETTEXT_WITH_LIBINTL_JAR" | sed -e 's,/[^/]*$,,' | sed -e 's,/bin$,,'`
+changequote([, ])dnl
+LIBINTL_JAR="$basedir"/share/gettext/libintl.jar
+AC_SUBST([LIBINTL_JAR])
+
+dnl Support for the po directory.
+AM_PO_SUBDIRS
+
+AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([javacomp.sh])
+AC_CONFIG_FILES([javaexec.sh])
+AC_CONFIG_FILES([m4/Makefile])
+AC_CONFIG_FILES([po/Makefile], [AM_POSTPROCESS_PO_MAKEFILE])
+AC_OUTPUT
diff --git a/gettext-tools/examples/hello-java-qtjambi/m4/Makefile.am b/gettext-tools/examples/hello-java-qtjambi/m4/Makefile.am
new file mode 100644 (file)
index 0000000..62ed854
--- /dev/null
@@ -0,0 +1,3 @@
+EXTRA_DIST = \
+  nls.m4 po.m4 \
+  gcj.m4 javacomp.m4 javaexec.m4 Test15.java Test15.class
diff --git a/gettext-tools/examples/hello-java-qtjambi/m4/Test15.class b/gettext-tools/examples/hello-java-qtjambi/m4/Test15.class
new file mode 100644 (file)
index 0000000..17812cc
Binary files /dev/null and b/gettext-tools/examples/hello-java-qtjambi/m4/Test15.class differ
diff --git a/gettext-tools/examples/hello-java-qtjambi/m4/Test15.java b/gettext-tools/examples/hello-java-qtjambi/m4/Test15.java
new file mode 100644 (file)
index 0000000..f4bcd2c
--- /dev/null
@@ -0,0 +1,26 @@
+// Test for Java 1.5 or newer.
+import java.util.*;
+public class Test15 {
+  public static void main (String[] args) {
+    try {
+      foo();
+    } catch (Throwable e) {
+      System.exit(1);
+    }
+    // Check the JVM version is at least 1.5.
+    String version = System.getProperty("java.specification.version");
+    int i = 0;
+    while (i < version.length()
+           && (Character.isDigit(version.charAt(i)) || version.charAt(i)=='.'))
+      i++;
+    float fversion = Float.valueOf(version.substring(0,i));
+    if (!(fversion >= 1.5f)) System.exit(1);
+    // Check the VM is not GNU libgcj.
+    String vm = System.getProperty("java.vm.name");
+    if (vm.startsWith("GNU")) System.exit(1);
+    System.exit(0);
+  }
+  private static List<Integer> foo() {
+    return new ArrayList<Integer>();
+  }
+}
diff --git a/gettext-tools/examples/hello-java-qtjambi/po/Makefile.am b/gettext-tools/examples/hello-java-qtjambi/po/Makefile.am
new file mode 100644 (file)
index 0000000..6de0494
--- /dev/null
@@ -0,0 +1,252 @@
+# Example for use of GNU gettext.
+# This file is in the public domain.
+#
+# Makefile configuration - processed by automake.
+
+# List of files which contain translatable strings.
+POTFILES = \
+  Hello.java
+
+# Usually the message domain is the same as the package name.
+DOMAIN = $(PACKAGE)
+
+# These options get passed to xgettext.
+XGETTEXT_OPTIONS =
+
+# This is the copyright holder that gets inserted into the header of the
+# $(DOMAIN).pot file.  Set this to the copyright holder of the surrounding
+# package.  (Note that the msgstr strings, extracted from the package's
+# sources, belong to the copyright holder of the package.)  Translators are
+# expected to transfer the copyright for their translations to this person
+# or entity, or to disclaim their copyright.  The empty string stands for
+# the public domain; in this case the translators are expected to disclaim
+# their copyright.
+COPYRIGHT_HOLDER = Yoyodyne, Inc.
+
+# This is the email address or URL to which the translators shall report
+# bugs in the untranslated strings:
+# - Strings which are not entire sentences, see the maintainer guidelines
+#   in the GNU gettext documentation, section 'Preparing Strings'.
+# - Strings which use unclear terms or require additional context to be
+#   understood.
+# - Strings which make invalid assumptions about notation of date, time or
+#   money.
+# - Pluralisation problems.
+# - Incorrect English spelling.
+# - Incorrect formatting.
+# It can be your email address, or a mailing list address where translators
+# can write to without being subscribed, or the URL of a web page through
+# which the translators can contact you.
+MSGID_BUGS_ADDRESS = bug-gnu-gettext@gnu.org
+
+MSGMERGE = msgmerge
+MSGMERGE_UPDATE = @MSGMERGE@ --update
+MSGCAT = msgcat
+MSGINIT = msginit
+MSGCONV = msgconv
+MSGFILTER = msgfilter
+
+# This is computed as $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
+POTFILES_DEPS = @POTFILES_DEPS@
+
+# This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).po)
+POFILES = @POFILES@
+# This is computed as $(foreach lang, $(LINGUAS), $(lang).po-update)
+UPDATEPOFILES = @UPDATEPOFILES@
+# This is computed as $(foreach lang, $(LINGUAS), $(lang).nop)
+DUMMYPOFILES = @DUMMYPOFILES@
+# This is computed as $(foreach lang, $(LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).properties)
+PROPERTIESFILES = @PROPERTIESFILES@
+# This is computed as $(foreach lang, $(LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).class)
+CLASSFILES = @CLASSFILES@
+
+# This is computed as
+# $(foreach lang, user-specified subset of $(LINGUAS), $(DOMAIN)_$(lang).properties)
+CATALOGS = @JAVACATALOGS@
+
+SUFFIXES = .po .sed .sin .nop .po-create .po-update
+
+.sin.sed:
+       sed -e '/^#/d' $< > t-$@
+       mv t-$@ $@
+
+
+all-local: stamp-po
+
+# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
+# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
+# we don't want to bother translators with empty POT files). We assume that
+# LINGUAS is empty in this case, i.e. $(POFILES) and $(PROPERTIESFILES) are
+# empty. In this case, stamp-po is a nop (i.e. a phony target).
+
+# stamp-po is a timestamp denoting the last time at which the CATALOGS have
+# been loosely updated. Its purpose is that when a developer or translator
+# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
+# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
+# invocations of "make" will do nothing. This timestamp would not be necessary
+# if updating the $(CATALOGS) would always touch them; however, the rule for
+# $(POFILES) has been designed to not touch files that don't need to be
+# changed.
+stamp-po: $(srcdir)/$(DOMAIN).pot
+       test ! -f $(srcdir)/$(DOMAIN).pot || \
+         $(MAKE) update-properties
+       @test ! -f $(srcdir)/$(DOMAIN).pot || { \
+         echo "touch stamp-po" && \
+         echo timestamp > stamp-poT && \
+         mv stamp-poT stamp-po; \
+       }
+
+# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
+# otherwise packages like GCC can not be built if only parts of the source
+# have been downloaded.
+
+# This target rebuilds $(DOMAIN).pot; it is an expensive operation.
+# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
+$(DOMAIN).pot-update: $(POTFILES_DEPS) remove-potcdate.sed
+       if LC_ALL=C grep 'GNU $(PACKAGE)' $(top_srcdir)/* 2>/dev/null | grep -v 'libtool:' >/dev/null; then \
+         package_gnu='GNU '; \
+       else \
+         package_gnu=''; \
+       fi; \
+       if test -n '$(MSGID_BUGS_ADDRESS)'; then \
+         msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
+       else \
+         msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
+       fi; \
+       case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
+         '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \
+           $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
+             --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
+             --copyright-holder='$(COPYRIGHT_HOLDER)' \
+             --msgid-bugs-address="$$msgid_bugs_address" \
+             $(POTFILES) \
+           ;; \
+         *) \
+           $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
+             --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
+             --copyright-holder='$(COPYRIGHT_HOLDER)' \
+             --package-name="$${package_gnu}$(PACKAGE)" \
+             --package-version='$(VERSION)' \
+             --msgid-bugs-address="$$msgid_bugs_address" \
+             $(POTFILES) \
+           ;; \
+       esac
+       test ! -f $(DOMAIN).po || { \
+         if test -f $(srcdir)/$(DOMAIN).pot; then \
+           sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
+           sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
+           if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
+             rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
+           else \
+             rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
+             mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
+           fi; \
+         else \
+           mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
+         fi; \
+       }
+
+# This rule has no dependencies: we don't need to update $(DOMAIN).pot at
+# every "make" invocation, only create it when it is missing.
+# Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
+$(srcdir)/$(DOMAIN).pot:
+       $(MAKE) $(DOMAIN).pot-update
+
+# This target rebuilds a PO file if $(DOMAIN).pot has changed.
+# Note that a PO file is not touched if it doesn't need to be changed.
+$(POFILES): $(srcdir)/$(DOMAIN).pot
+       @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
+       if test -f "$(srcdir)/$${lang}.po"; then \
+         test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
+         echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
+         cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
+       else \
+         $(MAKE) $${lang}.po-create; \
+       fi
+
+
+html ID:
+
+MOSTLYCLEANFILES =
+MOSTLYCLEANFILES += remove-potcdate.sed
+MOSTLYCLEANFILES += stamp-poT
+MOSTLYCLEANFILES += core core.* *.stackdump $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
+
+MAINTAINERCLEANFILES = stamp-po
+
+EXTRA_DIST = remove-potcdate.sin LINGUAS $(POFILES)
+
+# Hidden from automake, but really activated. Works around an automake-1.5 bug.
+#distdir: distdir1
+distdir1:
+       $(MAKE) update-po
+       if test -f $(srcdir)/$(DOMAIN).pot; then \
+         for file in $(DOMAIN).pot stamp-po; do \
+           if test -f $$file; then d=.; else d=$(srcdir); fi; \
+           cp -p $$d/$$file $(distdir)/$$file || exit 1; \
+         done; \
+       fi
+
+update-po: Makefile
+       $(MAKE) $(DOMAIN).pot-update
+       test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
+       $(MAKE) update-properties
+
+# General rule for creating PO files.
+
+.nop.po-create:
+       @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
+       echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
+       exit 1
+
+# General rule for updating PO files.
+
+.nop.po-update:
+       @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
+       tmpdir=`pwd`; \
+       echo "$$lang:"; \
+       test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
+       echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
+       cd $(srcdir); \
+       if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
+         if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
+           rm -f $$tmpdir/$$lang.new.po; \
+         else \
+           if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
+             :; \
+           else \
+             echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
+             exit 1; \
+           fi; \
+         fi; \
+       else \
+         echo "msgmerge for $$lang.po failed!" 1>&2; \
+         rm -f $$tmpdir/$$lang.new.po; \
+       fi
+
+$(DUMMYPOFILES):
+
+update-properties: Makefile $(DOMAIN).pot $(POFILES)
+       @echo "$(MSGINIT) -i $(DOMAIN).pot --no-translator -l en --properties-output -o $(top_srcdir)/$(DOMAIN).properties"; \
+       $(MSGINIT) -i $(DOMAIN).pot --no-translator -l en --properties-output -o $(top_srcdir)/$(DOMAIN).properties || { rm -f $(top_srcdir)/$(DOMAIN).properties; exit 1; }
+       @for f in $(POFILES); do \
+         lang=`echo $$f | sed -e 's,.*/,,' -e 's,\.po$$,,'`; \
+         echo "$(GMSGFMT) -c --statistics -o /dev/null $(srcdir)/$${lang}.po"; \
+         $(GMSGFMT) -c --statistics -o /dev/null $(srcdir)/$${lang}.po || exit 1; \
+         echo "$(MSGCAT) --properties-output -o $(top_srcdir)/$(DOMAIN)_$$lang.properties $(srcdir)/$${lang}.po"; \
+         $(MSGCAT) --properties-output -o $(top_srcdir)/$(DOMAIN)_$$lang.properties.tmp $(srcdir)/$${lang}.po || exit 1; \
+         mv $(top_srcdir)/$(DOMAIN)_$$lang.properties.tmp $(top_srcdir)/$(DOMAIN)_$$lang.properties || exit 1; \
+       done
+
+# Alternatively, we could create classes instead of properties files.
+update-classes: Makefile $(DOMAIN).pot $(POFILES)
+       @echo "$(MSGINIT) -i $(DOMAIN).pot --no-translator -l en --properties-output -o $(top_srcdir)/$(DOMAIN).properties"; \
+       $(MSGINIT) -i $(DOMAIN).pot --no-translator -l en --properties-output -o $(top_srcdir)/$(DOMAIN).properties || { rm -f $(top_srcdir)/$(DOMAIN).properties; exit 1; }
+       @for f in $(POFILES); do \
+         lang=`echo $$f | sed -e 's,.*/,,' -e 's,\.po$$,,'`; \
+         echo "$(GMSGFMT) -c --statistics -j -d $(top_srcdir) -r $(DOMAIN) -l $${lang} $(srcdir)/$${lang}.po"; \
+         $(GMSGFMT) -c --statistics -j -d $(top_srcdir) -r $(DOMAIN) -l $${lang} $(srcdir)/$${lang}.po || exit 1; \
+       done
+
+echo-catalogs:
+       @echo $(CATALOGS)
index 0f13d075d81107332be9f4d7f87a676d9752f25f..d2d3dca47fe32af8c5d3edbb65c48184c0aafa1a 100644 (file)
@@ -1,5 +1,5 @@
 ## Makefile for the gettext-tools/examples/po subdirectory of GNU gettext
-## Copyright (C) 1995-1998, 2000-2006 Free Software Foundation, Inc.
+## Copyright (C) 1995-1998, 2000-2007 Free Software Foundation, Inc.
 ##
 ## This program is free software: you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -45,6 +45,7 @@ POTFILES = \
   hello-java/Hello.java \
   hello-java-awt/Hello.java \
   hello-java-swing/Hello.java \
+  hello-java-qtjambi/Hello.java \
   hello-csharp/hello.cs \
   hello-csharp-forms/hello.cs \
   hello-gawk/hello.awk \
@@ -77,6 +78,7 @@ SMALLPOTS = \
   hello-java.pot \
   hello-java-awt.pot \
   hello-java-swing.pot \
+  hello-java-qtjambi.pot \
   hello-csharp.pot \
   hello-csharp-forms.pot \
   hello-gawk.pot \
@@ -259,6 +261,9 @@ hello-java-awt.pot : $(POTFILES_DEPS)
 hello-java-swing.pot : $(POTFILES_DEPS)
        $(SHELL) '$(srcdir)/xsmallpot.sh' '$(srcdir)' hello-java-swing
 
+hello-java-qtjambi.pot : $(POTFILES_DEPS)
+       $(SHELL) '$(srcdir)/xsmallpot.sh' '$(srcdir)' hello-java-qtjambi
+
 hello-csharp.pot : $(POTFILES_DEPS)
        $(SHELL) '$(srcdir)/xsmallpot.sh' '$(srcdir)' hello-csharp
 
@@ -384,6 +389,7 @@ SMALLPOFILES_FOR_lang = \
   ../hello-java/po/$$lang.po \
   ../hello-java-awt/po/$$lang.po \
   ../hello-java-swing/po/$$lang.po \
+  ../hello-java-qtjambi/po/$$lang.po \
   ../hello-csharp/po/$$lang.po \
   ../hello-csharp-forms/po/$$lang.po \
   ../hello-gawk/po/$$lang.po \
@@ -451,6 +457,9 @@ SMALLPOFILES_FOR_lang = \
 ../hello-java-swing/po/$(LL).po: hello-java-swing.pot $(LL).po
        $(SHELL) mmsmallpo.sh hello-java-swing $(LL)
 
+../hello-java-qtjambi/po/$(LL).po: hello-java-qtjambi.pot $(LL).po
+       $(SHELL) mmsmallpo.sh hello-java-qtjambi $(LL)
+
 ../hello-csharp/po/$(LL).po: hello-csharp.pot $(LL).po
        $(SHELL) mmsmallpo.sh hello-csharp $(LL)