summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog26
-rw-r--r--src/Makefile.am49
-rw-r--r--src/gnu/gettext/DumpResource.java214
-rw-r--r--src/msgunfmt.c102
-rw-r--r--src/msgunfmt.h25
-rw-r--r--src/read-java.c137
-rw-r--r--src/read-java.h30
-rw-r--r--src/read-po.c18
-rw-r--r--src/read-po.h5
9 files changed, 593 insertions, 13 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index fc641c7..828391d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,31 @@
2001-09-08 Bruno Haible <haible@clisp.cons.org>
+ * msgunfmt.h: New file.
+ * msgunfmt.c (verbose): New variable.
+ (java_mode, java_resource_name, java_locale_name): New variables.
+ (long_options): Add --java, --locale, --resource, --verbose.
+ (main): Recognize new options -j, -l, -r, -v. Handle java mode
+ differently.
+ (usage): Document --java, --resource, --locale, --verbose.
+ * read-java.h: New file.
+ * read-java.c: New file.
+ * read-po.h (read_po): New declaration.
+ * read-po.c (read_po): New function.
+ * gnu/gettext/DumpResource.java: New file.
+ * Makefile.am (jardir): New variable.
+ (DEFS): Define GETTEXTJAR, for read-java.c.
+ (JAR): New variable.
+ (JAVACOMP): New variable.
+ (msgunfmt_SOURCES): Add open-po.c, po-gram-gen.y, po-hash-gen.y,
+ po-charset.c, po-lex.c, po.c, read-po.c, dir-list.c, read-java.c.
+ (all-local, all-java-no, all-java-yes, gnu/gettext/DumpResource.class,
+ gettext.jar, install-data-local, install-java-no, install-java-yes,
+ installdirs-local, installdirs-java-no, installdirs-java-yes,
+ uninstall-local, uninstall-java-no, uninstall-java-yes): New rules.
+ (CLEANFILES): New variable.
+
+2001-09-08 Bruno Haible <haible@clisp.cons.org>
+
* msgexec.c (nonintr_select): Add function prototype.
* xgettext.c (scan_java_file): Add function prototype.
diff --git a/src/Makefile.am b/src/Makefile.am
index 745db1b..1a0fad5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -31,14 +31,19 @@ msgl-cat.h msgfmt.h read-mo.h write-mo.h xgettext.h x-c.h x-po.h x-java.h
EXTRA_DIST = FILES
localedir = $(datadir)/locale
+jardir = $(datadir)/gettext
INCLUDES = -I. -I$(srcdir) -I.. -I$(top_srcdir)/lib -I../intl \
-I$(top_srcdir)/intl
-DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
+DEFS = -DLOCALEDIR=\"$(localedir)\" -DGETTEXTJAR=\"$(jardir)/gettext.jar\" \
+@DEFS@
LDADD = ../lib/libnlsut.a @INTLLIBS@
SED = sed
YACC = @YACC@ -d
+JAR = @JAR@
+JAVACOMP = $(SHELL) ../lib/javacomp.sh
+
# Source dependencies.
gettext_SOURCES = gettext.c
@@ -52,8 +57,9 @@ format.c format-c.c format-java.c format-lisp.c format-python.c format-ycp.c
msgmerge_SOURCES = message.c msgmerge.c open-po.c po-gram-gen.y po-hash-gen.y \
po-charset.c po-lex.c po.c read-po.c str-list.c dir-list.c write-po.c \
msgl-ascii.c
-msgunfmt_SOURCES = message.c msgunfmt.c str-list.c write-po.c msgl-ascii.c \
-read-mo.c
+msgunfmt_SOURCES = message.c msgunfmt.c open-po.c po-gram-gen.y po-hash-gen.y \
+po-charset.c po-lex.c po.c read-po.c str-list.c dir-list.c write-po.c \
+msgl-ascii.c read-mo.c read-java.c
xgettext_SOURCES = message.c open-po.c po-gram-gen.y po-hash-gen.y \
po-charset.c po-lex.c po.c str-list.c xgettext.c dir-list.c write-po.c \
msgl-ascii.c file-list.c x-c.c x-po.c x-java.l \
@@ -100,6 +106,9 @@ msgexec_LDADD = ../lib/libnlsut.a @INTLLIBS@ @LIBICONV@
msggrep_LDADD = ../lib/libnlsut.a @INTLLIBS@ @LIBICONV@
msguniq_LDADD = ../lib/libnlsut.a @INTLLIBS@ @LIBICONV@
+
+# Special rules for bison and flex generated files.
+
BUILT_SOURCES = po-gram-gen.c po-hash-gen.c po-gram-gen.h po-hash-gen.h
po-lex.o: po-gram-gen2.h
@@ -112,3 +121,37 @@ x-java.c: x-java.l
test "$(LEX)" = ":" || mv $@-tmp $@
DISTCLEANFILES = po-gram-gen2.h
+
+
+# Special rules for Java compilation.
+
+all-local: all-java-@BUILDJAVA@
+all-java-no:
+all-java-yes: gettext.jar
+
+gnu/gettext/DumpResource.class: $(srcdir)/gnu/gettext/DumpResource.java
+ $(JAVACOMP) -d . $(srcdir)/gnu/gettext/DumpResource.java
+
+gettext.jar: gnu/gettext/DumpResource.class
+ $(JAR) cf $@ gnu/gettext/DumpResource*.class
+
+CLEANFILES = gettext.jar gnu/gettext/*.class
+
+install-data-local: install-java-@BUILDJAVA@
+install-java-no:
+install-java-yes: all-java-yes
+ $(INSTALL_DATA) gettext.jar $(DESTDIR)$(jardir)/gettext.jar
+
+installdirs-local: installdirs-java-@BUILDJAVA@
+installdirs-java-no:
+installdirs-java-yes:
+ $(mkinstalldirs) $(DESTDIR)$(jardir)
+
+uninstall-local: uninstall-java-@BUILDJAVA@
+uninstall-java-no:
+uninstall-java-yes:
+ $(RM) $(DESTDIR)$(jardir)/gettext.jar
+
+
+# One more automake bug.
+installdirs: installdirs-local
diff --git a/src/gnu/gettext/DumpResource.java b/src/gnu/gettext/DumpResource.java
new file mode 100644
index 0000000..692cd11
--- /dev/null
+++ b/src/gnu/gettext/DumpResource.java
@@ -0,0 +1,214 @@
+/* GNU gettext for Java
+ * Copyright (C) 2001 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
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package gnu.gettext;
+
+import java.lang.reflect.*;
+import java.util.*;
+import java.io.*;
+
+/**
+ * This programs dumps a resource as a PO file. The resource must be
+ * accessible through the CLASSPATH.
+ *
+ * @author Bruno Haible
+ */
+public class DumpResource {
+ private Writer out;
+ private void dumpString (String str) throws IOException {
+ int n = str.length();
+ out.write('"');
+ for (int i = 0; i < n; i++) {
+ char c = str.charAt(i);
+ if (c == 0x0008) {
+ out.write('\\'); out.write('b');
+ } else if (c == 0x000c) {
+ out.write('\\'); out.write('f');
+ } else if (c == 0x000a) {
+ out.write('\\'); out.write('n');
+ } else if (c == 0x000d) {
+ out.write('\\'); out.write('r');
+ } else if (c == 0x0009) {
+ out.write('\\'); out.write('t');
+ } else if (c == '\\' || c == '"') {
+ out.write('\\'); out.write(c);
+ } else
+ out.write(c);
+ }
+ out.write('"');
+ }
+ private void dumpMessage (String msgid, String msgid_plural, Object msgstr) throws IOException {
+ out.write("msgid "); dumpString(msgid); out.write('\n');
+ if (msgid_plural != null) {
+ out.write("msgid_plural "); dumpString(msgid_plural); out.write('\n');
+ for (int i = 0; i < ((String[])msgstr).length; i++) {
+ out.write("msgstr[" + i + "] ");
+ dumpString(((String[])msgstr)[i]);
+ out.write('\n');
+ }
+ } else {
+ out.write("msgstr "); dumpString((String)msgstr); out.write('\n');
+ }
+ out.write('\n');
+ }
+ private ResourceBundle catalog;
+ private Method lookupMethod;
+ private Field pluralField;
+ // Lookup the value corresponding to a key found in catalog.getKeys().
+ // Here we assume that the catalog returns a non-inherited value for
+ // these keys. FIXME: Not true. Better see whether handleGetObject is
+ // public - it is in ListResourceBundle and PropertyResourceBundle.
+ private Object lookup (String key) {
+ Object value = null;
+ if (lookupMethod != null) {
+ try {
+ value = lookupMethod.invoke(catalog, new Object[] { key });
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.getTargetException().printStackTrace();
+ }
+ } else {
+ try {
+ value = catalog.getObject(key);
+ } catch (MissingResourceException e) {
+ }
+ }
+ return value;
+ }
+ private void dump () throws IOException {
+ lookupMethod = null;
+ try {
+ lookupMethod = catalog.getClass().getMethod("lookup", new Class[] { java.lang.String.class });
+ } catch (NoSuchMethodException e) {
+ } catch (SecurityException e) {
+ }
+ pluralField = null;
+ try {
+ pluralField = catalog.getClass().getField("plural");
+ } catch (NoSuchFieldException e) {
+ } catch (SecurityException e) {
+ }
+ // Search for the header entry.
+ {
+ Object header_entry = null;
+ Enumeration keys = catalog.getKeys();
+ while (keys.hasMoreElements())
+ if ("".equals(keys.nextElement())) {
+ header_entry = lookup("");
+ break;
+ }
+ // If there is no header entry, fake one.
+ // FIXME: This is not needed; right after po_lex_charset_init set
+ // the PO charset to UTF-8.
+ if (header_entry == null)
+ header_entry = "Content-Type: text/plain; charset=UTF-8\n";
+ dumpMessage("",null,header_entry);
+ }
+ // Now the other messages.
+ {
+ Enumeration keys = catalog.getKeys();
+ Object plural = null;
+ if (pluralField != null)
+ try {
+ plural = pluralField.get(catalog);
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ if (plural instanceof String[]) {
+ // A GNU gettext created class with plural handling, Java2 format.
+ int i = 0;
+ while (keys.hasMoreElements()) {
+ String key = (String)keys.nextElement();
+ Object value = lookup(key);
+ String key_plural = (value instanceof String[] ? ((String[])plural)[i++] : null);
+ if (!"".equals(key))
+ dumpMessage(key,key_plural,value);
+ }
+ if (i != ((String[])plural).length)
+ throw new RuntimeException("wrong plural field length");
+ } else if (plural instanceof Hashtable) {
+ // A GNU gettext created class with plural handling, Java format.
+ while (keys.hasMoreElements()) {
+ String key = (String)keys.nextElement();
+ if (!"".equals(key)) {
+ Object value = lookup(key);
+ String key_plural = (value instanceof String[] ? (String)((Hashtable)plural).get(key) : null);
+ dumpMessage(key,key_plural,value);
+ }
+ }
+ } else if (plural == null) {
+ // No plural handling.
+ while (keys.hasMoreElements()) {
+ String key = (String)keys.nextElement();
+ if (!"".equals(key))
+ dumpMessage(key,null,lookup(key));
+ }
+ } else
+ throw new RuntimeException("wrong plural field value");
+ }
+ }
+
+ public DumpResource (String resource_name, String locale_name) {
+ // Split locale_name into language_country_variant.
+ String language;
+ String country;
+ String variant;
+ language = locale_name;
+ {
+ int i = language.indexOf('_');
+ if (i >= 0) {
+ country = language.substring(i+1);
+ language = language.substring(0,i);
+ } else
+ country = "";
+ }
+ {
+ int j = country.indexOf('_');
+ if (j >= 0) {
+ variant = country.substring(j+1);
+ country = country.substring(0,j);
+ } else
+ variant = "";
+ }
+ Locale locale = new Locale(language,country,variant);
+ // Get the resource.
+ ResourceBundle catalog = ResourceBundle.getBundle(resource_name,locale);
+ // We are only interested in the messsages belonging to the locale
+ // itself, not in the inherited messages. But catalog.getLocale() exists
+ // only in Java2 and sometimes differs from the given locale.
+ try {
+ Writer w1 = new OutputStreamWriter(System.out,"UTF8");
+ Writer w2 = new BufferedWriter(w1);
+ this.out = w2;
+ this.catalog = catalog;
+ dump();
+ w2.close();
+ w1.close();
+ System.out.flush();
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ public static void main (String[] args) {
+ new DumpResource(args[0], args.length > 1 ? args[1] : "");
+ System.exit(0);
+ }
+}
diff --git a/src/msgunfmt.c b/src/msgunfmt.c
index c44aba4..14c8a8b 100644
--- a/src/msgunfmt.c
+++ b/src/msgunfmt.c
@@ -21,6 +21,7 @@
#endif
#include <getopt.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
@@ -29,13 +30,23 @@
#include "progname.h"
#include "system.h"
#include "message.h"
+#include "msgunfmt.h"
#include "read-mo.h"
+#include "read-java.h"
#include "write-po.h"
#include "libgettext.h"
#define _(str) gettext (str)
+/* Be more verbose. */
+bool verbose;
+
+/* Java mode input file specification. */
+static bool java_mode;
+static const char *java_resource_name;
+static const char *java_locale_name;
+
/* Force output of PO file even if empty. */
static int force_po;
@@ -46,10 +57,14 @@ static const struct option long_options[] =
{ "force-po", no_argument, &force_po, 1 },
{ "help", no_argument, NULL, 'h' },
{ "indent", no_argument, NULL, 'i' },
+ { "java", no_argument, NULL, 'j' },
+ { "locale", required_argument, NULL, 'l' },
{ "no-escape", no_argument, NULL, 'e' },
{ "output-file", required_argument, NULL, 'o' },
+ { "resource", required_argument, NULL, 'r' },
{ "sort-output", no_argument, NULL, 's' },
{ "strict", no_argument, NULL, 'S' },
+ { "verbose", no_argument, NULL, 'v' },
{ "version", no_argument, NULL, 'V' },
{ "width", required_argument, NULL, 'w', },
{ NULL, 0, NULL, 0 }
@@ -70,7 +85,6 @@ main (argc, argv)
bool do_help = false;
bool do_version = false;
const char *output_file = "-";
- message_list_ty *mlp;
msgdomain_list_ty *result;
bool sort_by_msgid = false;
@@ -87,7 +101,8 @@ main (argc, argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
- while ((optchar = getopt_long (argc, argv, "eEhio:sVw:", long_options, NULL))
+ while ((optchar = getopt_long (argc, argv, "eEhijl:o:r:svVw:", long_options,
+ NULL))
!= EOF)
switch (optchar)
{
@@ -111,10 +126,22 @@ main (argc, argv)
message_print_style_indent ();
break;
+ case 'j':
+ java_mode = true;
+ break;
+
+ case 'l':
+ java_locale_name = optarg;
+ break;
+
case 'o':
output_file = optarg;
break;
+ case 'r':
+ java_resource_name = optarg;
+ break;
+
case 's':
sort_by_msgid = true;
break;
@@ -123,6 +150,10 @@ main (argc, argv)
message_print_style_uniforum ();
break;
+ case 'v':
+ verbose = true;
+ break;
+
case 'V':
do_version = true;
break;
@@ -160,19 +191,54 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
if (do_help)
usage (EXIT_SUCCESS);
+ /* Check for contradicting options. */
+ if (java_mode)
+ {
+ if (optind < argc)
+ {
+ error (EXIT_FAILURE, 0,
+ _("%s and explicit file names are mutually exclusive"),
+ "--java-mode");
+ }
+ }
+ else
+ {
+ if (java_resource_name != NULL)
+ {
+ error (EXIT_SUCCESS, 0, _("%s is only valid with %s"),
+ "--resource", "--java-mode");
+ usage (EXIT_FAILURE);
+ }
+ if (java_locale_name != NULL)
+ {
+ error (EXIT_SUCCESS, 0, _("%s is only valid with %s"),
+ "--locale", "--java-mode");
+ usage (EXIT_FAILURE);
+ }
+ }
+
/* Read the given .mo file. */
- mlp = message_list_alloc ();
- if (optind < argc)
+ if (java_mode)
{
- do
- read_mo_file (mlp, argv[optind]);
- while (++optind < argc);
+ result = msgdomain_read_java (java_resource_name, java_locale_name);
}
else
- read_mo_file (mlp, "-");
+ {
+ message_list_ty *mlp;
- result = msgdomain_list_alloc ();
- result->item[0]->messages = mlp;
+ mlp = message_list_alloc ();
+ if (optind < argc)
+ {
+ do
+ read_mo_file (mlp, argv[optind]);
+ while (++optind < argc);
+ }
+ else
+ read_mo_file (mlp, "-");
+
+ result = msgdomain_list_alloc ();
+ result->item[0]->messages = mlp;
+ }
/* Sorting the list of messages. */
if (sort_by_msgid)
@@ -213,6 +279,12 @@ Mandatory arguments to long options are mandatory for short options too.\n\
printf ("\n");
/* xgettext: no-wrap */
printf (_("\
+Operation mode:\n\
+ -j, --java Java mode: generate a Java ResourceBundle class\n\
+"));
+ printf ("\n");
+ /* xgettext: no-wrap */
+ printf (_("\
Input file location:\n\
FILE ... input .mo files\n\
If no input file is given or if it is -, standard input is read.\n\
@@ -220,6 +292,15 @@ If no input file is given or if it is -, standard input is read.\n\
printf ("\n");
/* xgettext: no-wrap */
printf (_("\
+Input file location in Java mode:
+ -r, --resource=RESOURCE resource name
+ -l, --locale=LOCALE locale name, either language or language_COUNTRY
+The class name is determined by appending the locale name to the resource name,
+separated with an underscore. The class is located using the CLASSPATH.
+"));
+ printf ("\n");
+ /* xgettext: no-wrap */
+ printf (_("\
Output file location:\n\
-o, --output-file=FILE write output to specified file\n\
The results are written to standard output if no output file is specified\n\
@@ -243,6 +324,7 @@ Output details:\n\
Informative output:\n\
-h, --help display this help and exit\n\
-V, --version output version information and exit\n\
+ -v, --verbose increase verbosity level
"));
printf ("\n");
fputs (_("Report bugs to <bug-gnu-gettext@gnu.org>.\n"),
diff --git a/src/msgunfmt.h b/src/msgunfmt.h
new file mode 100644
index 0000000..ebec6b8
--- /dev/null
+++ b/src/msgunfmt.h
@@ -0,0 +1,25 @@
+/* msgunfmt specifics
+ Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
+ Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, April 1995.
+
+ 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _MSGUNFMT_H
+#define _MSGUNFMT_H
+
+/* Be more verbose. */
+extern bool verbose;
+
+#endif /* _MSGUNFMT_H */
diff --git a/src/read-java.c b/src/read-java.c
new file mode 100644
index 0000000..a2f3dfc
--- /dev/null
+++ b/src/read-java.c
@@ -0,0 +1,137 @@
+/* Reading Java ResourceBundles.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ Written by Bruno Haible <haible@clisp.cons.org>, 2001.
+
+ 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification. */
+#include "read-java.h"
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "msgunfmt.h"
+#include "javaexec.h"
+#include "pipe.h"
+#include "wait-process.h"
+#include "read-po.h"
+#include "error.h"
+#include "system.h"
+#include "libgettext.h"
+
+#define _(str) gettext (str)
+
+
+/* Prototypes for local functions. Needed to ensure compiler checking of
+ function argument counts despite of K&R C function definition syntax. */
+static bool execute_and_read_po_output PARAMS ((const char *progname,
+ const char *prog_path,
+ char **prog_argv,
+ void *private_data));
+
+
+/* A Java resource name can only be manipulated by a Java virtual machine.
+ So we start a JVM to execute the DumpResource program, and read its
+ output, which is .po format without comments. */
+
+struct locals
+{
+ /* OUT */
+ msgdomain_list_ty *mdlp;
+};
+
+static bool
+execute_and_read_po_output (progname, prog_path, prog_argv, private_data)
+ const char *progname;
+ const char *prog_path;
+ char **prog_argv;
+ void *private_data;
+{
+ struct locals *l = (struct locals *) private_data;
+ pid_t child;
+ int fd[1];
+ FILE *fp;
+ int exitstatus;
+
+ /* Open a pipe to the JVM. */
+ child = create_pipe_in (progname, prog_path, prog_argv, "/dev/null", fd);
+
+ fp = fdopen (fd[0], "r");
+ if (fp == NULL)
+ error (EXIT_FAILURE, errno, _("fdopen() failed"));
+
+ /* Read the message list. */
+ l->mdlp = read_po (fp, "(pipe)", "(pipe)");
+
+ fclose (fp);
+
+ /* Remove zombie process from process list, and retrieve exit status. */
+ exitstatus = wait_subprocess (child, progname);
+ if (exitstatus != 0)
+ error (EXIT_FAILURE, 0, _("%s subprocess failed with exit code %d"),
+ progname, exitstatus);
+
+ return 0;
+}
+
+
+msgdomain_list_ty *
+msgdomain_read_java (resource_name, locale_name)
+ const char *resource_name;
+ const char *locale_name;
+{
+ const char *class_name = "gnu.gettext.DumpResource";
+ const char *gettextjar;
+ const char *args[3];
+ struct locals locals;
+
+ /* Make it possible to override the gettext.jar location. This is
+ necessary for running the testsuite before "make install". */
+ gettextjar = getenv ("GETTEXTJAR");
+ if (gettextjar == NULL || gettextjar[0] == '\0')
+ gettextjar = GETTEXTJAR;
+
+ /* Assign a default value to the resource name. */
+ if (resource_name == NULL)
+ resource_name = "Messages";
+
+ /* Prepare arguments. */
+ args[0] = resource_name;
+ if (locale_name != NULL)
+ {
+ args[1] = locale_name;
+ args[2] = NULL;
+ }
+ else
+ args[1] = NULL;
+
+ /* Dump the resource and retrieve the resulting output.
+ Here we use the user's CLASSPATH, not a minimal one, so that the
+ resource can be found. */
+ if (execute_java_class (class_name, &gettextjar, 1, false,
+ args,
+ verbose,
+ execute_and_read_po_output, &locals))
+ /* An error message should already have been provided. */
+ exit (EXIT_FAILURE);
+
+ return locals.mdlp;
+}
diff --git a/src/read-java.h b/src/read-java.h
new file mode 100644
index 0000000..9b9e079
--- /dev/null
+++ b/src/read-java.h
@@ -0,0 +1,30 @@
+/* Reading Java ResourceBundles.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ Written by Bruno Haible <haible@clisp.cons.org>, 2001.
+
+ 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _READ_JAVA_H
+#define _READ_JAVA_H
+
+#include "message.h"
+
+/* Read the Java resource given by resource_name and locale_name.
+ Returns a list of messages. */
+extern msgdomain_list_ty *
+ msgdomain_read_java PARAMS ((const char *resource_name,
+ const char *locale_name));
+
+#endif /* _READ_JAVA_H */
diff --git a/src/read-po.c b/src/read-po.c
index 78d5a5b..2e08b0c 100644
--- a/src/read-po.c
+++ b/src/read-po.c
@@ -337,6 +337,24 @@ static po_method_ty readall_methods =
msgdomain_list_ty *
+read_po (fp, real_filename, logical_filename)
+ FILE *fp;
+ const char *real_filename;
+ const char *logical_filename;
+{
+ po_ty *pop;
+ msgdomain_list_ty *mdlp;
+
+ pop = po_alloc (&readall_methods);
+ po_lex_pass_obsolete_entries (true);
+ po_scan (pop, fp, real_filename, logical_filename);
+ mdlp = ((readall_class_ty *) pop)->mdlp;
+ po_free (pop);
+ return mdlp;
+}
+
+
+msgdomain_list_ty *
read_po_file (filename)
const char *filename;
{
diff --git a/src/read-po.h b/src/read-po.h
index 05aa4a7..455f957 100644
--- a/src/read-po.h
+++ b/src/read-po.h
@@ -22,6 +22,7 @@
#include "message.h"
#include <stdbool.h>
+#include <stdio.h>
/* If nonzero, remember comments for file name and line number for each
msgid, if present in the reference input. Defaults to true. */
@@ -32,6 +33,10 @@ extern int line_comment;
appropriately. Defaults to false. */
extern bool allow_duplicates;
+/* Read the input file from a stream. Returns a list of messages. */
+extern msgdomain_list_ty *read_po PARAMS ((FILE *fp, const char *real_filename,
+ const char *logical_filename));
+
/* Read the input file with the name INPUT_NAME. The ending .po is added
if necessary. If INPUT_NAME is not an absolute file name and the file is
not found, the list of directories in "dir-list.h" is searched. Returns