]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
New language specific tests.
authorBruno Haible <bruno@clisp.org>
Tue, 27 Nov 2001 13:16:07 +0000 (13:16 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 21 Jun 2009 21:27:01 +0000 (23:27 +0200)
12 files changed:
ChangeLog
configure.in
tests/ChangeLog
tests/Makefile.am
tests/lang-c [new file with mode: 0755]
tests/lang-c++ [new file with mode: 0755]
tests/lang-java [new file with mode: 0755]
tests/lang-objc [new file with mode: 0755]
tests/lang-pascal [new file with mode: 0755]
tests/lang-po [new file with mode: 0755]
tests/lang-rst [new file with mode: 0755]
tests/lang-ycp [new file with mode: 0755]

index ad47d05bd6dc3f76ad5525de40c01686663a92de..c89c198acedb7e71892920fbe8f237f3f11a2594 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2001-11-25  Bruno Haible  <bruno@clisp.org>
+
+       * configure.in: Check for C++ compiler.
+
 2001-11-18  Bruno Haible  <haible@clisp.cons.org>
 
        * configure.in: Make misc/gettextize executable.
index 5daa38bd5e531271a96fa201436bce4837b33b5b..f7fa0d265fa341d6f85d7078f2cdcd97e1b2c755 100644 (file)
@@ -110,6 +110,12 @@ dnl Check for tools needed for formatting man pages.
 CROSS_COMPILING=$cross_compiling
 AC_SUBST(CROSS_COMPILING)
 
+dnl Checks for optional programs for the tests/lang-* tests.
+AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, :)
+if test "$CXX" != ":"; then
+  AC_PROG_CXX_WORKS
+fi
+
 dnl Generate the version information file in the intl/ directory.
 test -d intl || mkdir intl
 echo "GNU gettext library from $PACKAGE-$VERSION" > intl/VERSION
index 034ca40b2bd4ef08fa2f6d5e777182b5bf7b9194..956ced6231d577e0b05d7ce4aeae106e5d0464c9 100644 (file)
@@ -1,3 +1,17 @@
+2001-11-25  Bruno Haible  <bruno@clisp.org>
+
+       * lang-c: New file.
+       * lang-c++: New file.
+       * lang-objc: New file.
+       * lang-java: New file.
+       * lang-pascal: New file.
+       * lang-ycp: New file.
+       * lang-po: New file.
+       * lang-rst: New file.
+       * Makefile.am (TESTS): Add them.
+       (TESTS_ENVIRONMENT): Pass OBJEXT, EXEEXT, CC, CFLAGS, CXX, CXXFLAGS,
+       CPPFLAGS, LDFLAGS, INTLLIBS, TESTJAVA variables to the tests.
+
 2001-11-17  Bruno Haible  <haible@clisp.cons.org>
 
        * Makefile.am (TESTS); Add msgfmt-7, msgfmt-8, msgfmt-9, msgmerge-13.
index 18bf67a1f635a6824d7f58a146902879ac1a0cb9..22dadd7d142a00e1b27ecc83f3c7863f4ef0e70d 100644 (file)
@@ -42,7 +42,8 @@ TESTS = gettext-1 gettext-2 \
        format-python-1 format-python-2 \
        format-pascal-1 format-pascal-2 \
        format-ycp-1 format-ycp-2 \
-       plural-1 plural-2
+       plural-1 plural-2 \
+       lang-c lang-c++ lang-objc lang-java lang-pascal lang-ycp lang-po lang-rst
 
 EXTRA_DIST = $(TESTS) test.mo xg-test1.ok.po msguniq-a.in msguniq-a.out
 
@@ -59,6 +60,12 @@ TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) PATH=.:../src:$$PATH \
                    MSGUNFMT=`echo msgunfmt|sed '$(transform)'` \
                    MSGCAT=`echo msgcat|sed '$(transform)'` \
                    MSGUNIQ=`echo msguniq|sed '$(transform)'` \
+                   OBJEXT='@OBJEXT@' EXEEXT='@EXEEXT@' \
+                   CC='@CC@' CFLAGS='@CFLAGS@' \
+                   CXX='@CXX@' CXXFLAGS='@CXXFLAGS@' \
+                   CPPFLAGS='@CPPFLAGS@' LDFLAGS='@LDFLAGS@' \
+                   INTLLIBS='@INTLLIBS@' \
+                   TESTJAVA='@TESTJAVA@' \
                    $(SHELL)
 
 xg-test1.ok.po: $(top_srcdir)/src/xgettext.c $(top_srcdir)/src/msgfmt.c \
diff --git a/tests/lang-c b/tests/lang-c
new file mode 100755 (executable)
index 0000000..2022f9c
--- /dev/null
@@ -0,0 +1,129 @@
+#! /bin/sh
+
+# Test of gettext facilities in the C language.
+# Assumes an fr_FR locale is installed.
+# Assumes the following packages are installed: gcc.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles prog.c"
+cat <<\EOF > prog.c
+#include <libintl.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#define _(string) gettext (string)
+
+int main (argc, argv)
+  int argc;
+  char *argv[];
+{
+  int n = atoi (argv[1]);
+
+  if (setlocale (LC_ALL, "") == NULL)
+    {
+      fprintf (stderr, "Couldn't set locale.\n");
+      exit (77);
+    }
+
+  textdomain ("prog");
+  bindtextdomain ("prog", ".");
+
+  printf (_("'Your command, please?', asked the waiter."));
+  printf ("\n");
+
+  printf (ngettext ("a piece of cake", "%d pieces of cake", n), n);
+  printf ("\n");
+
+  printf (_("%s is replaced by %s."), "FF", "EUR");
+  printf ("\n");
+
+  exit (0);
+}
+EOF
+
+# Variable needed by INTLLIBS.
+top_builddir=..
+
+tmpfiles="$tmpfiles prog.${OBJEXT} prog${EXEEXT}"
+${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o prog prog.c -I../intl ${INTLLIBS} \
+  || exit 1
+
+tmpfiles="$tmpfiles prog.pot"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} -o prog.pot --omit-header --no-location -k_ prog.c
+
+tmpfiles="$tmpfiles prog.ok"
+cat <<EOF > prog.ok
+msgid "'Your command, please?', asked the waiter."
+msgstr ""
+
+msgid "a piece of cake"
+msgid_plural "%d pieces of cake"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format
+msgid "%s is replaced by %s."
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} prog.ok prog.pot || exit 1
+
+tmpfiles="$tmpfiles fr.po"
+cat <<\EOF > fr.po
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+msgid "'Your command, please?', asked the waiter."
+msgstr "«Votre commande, s'il vous plait», dit le garçon."
+
+# Les gateaux allemands sont les meilleurs du monde.
+msgid "a piece of cake"
+msgid_plural "%d pieces of cake"
+msgstr[0] "un morceau de gateau"
+msgstr[1] "%d morceaux de gateau"
+
+# Reverse the arguments.
+#, c-format
+msgid "%s is replaced by %s."
+msgstr "%2$s remplace %1$s."
+EOF
+
+tmpfiles="$tmpfiles fr.po.new"
+: ${MSGMERGE=msgmerge}
+${MSGMERGE} -q -o fr.po.new fr.po prog.pot
+
+: ${DIFF=diff}
+${DIFF} fr.po fr.po.new || exit 1
+
+tmpfiles="$tmpfiles fr"
+test -d fr || mkdir fr
+test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
+
+: ${MSGFMT=msgfmt}
+${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
+
+tmpfiles="$tmpfiles prog.ok prog.out"
+: ${DIFF=diff}
+cat <<\EOF > prog.ok
+«Votre commande, s'il vous plait», dit le garçon.
+2 morceaux de gateau
+EUR remplace FF.
+EOF
+
+LANGUAGE= LC_ALL=fr_FR ./prog 2 > prog.out
+case $? in
+  0) ;;
+  77) echo "SKIP: lang-c"; exit 77;;
+  *) exit 1;;
+esac
+${DIFF} prog.ok prog.out || exit 1
+
+rm -fr $tmpfiles
+
+exit 0
diff --git a/tests/lang-c++ b/tests/lang-c++
new file mode 100755 (executable)
index 0000000..f579963
--- /dev/null
@@ -0,0 +1,129 @@
+#! /bin/sh
+
+# Test of gettext facilities in the C++ language.
+# Assumes an fr_FR locale is installed.
+# Assumes the following packages are installed: gcc g++.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+# Test whether a C++ compiler is found.
+if test "${CXX}" = ":"; then
+  echo "SKIP: lang-c++"; exit 77
+fi
+
+tmpfiles="$tmpfiles prog.cc"
+cat <<\EOF > prog.cc
+#include <iostream.h>
+#include <libintl.h>
+#include <locale.h>
+#include <stdlib.h>
+#define _(string) gettext (string)
+
+int main (int argc, char *argv[])
+{
+  int n = atoi (argv[1]);
+
+  if (setlocale (LC_ALL, "") == NULL)
+    {
+      cerr << "Couldn't set locale." << endl;
+      exit (77);
+    }
+
+  textdomain ("prog");
+  bindtextdomain ("prog", ".");
+
+  cout << _("'Your command, please?', asked the waiter.") << endl;
+
+  cout.form (ngettext ("a piece of cake", "%d pieces of cake", n), n);
+  cout << endl;
+
+  cout.form (_("%s is replaced by %s."), "FF", "EUR");
+  cout << endl;
+}
+EOF
+
+# Variable needed by INTLLIBS.
+top_builddir=..
+
+tmpfiles="$tmpfiles prog.${OBJEXT} prog${EXEEXT}"
+${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} -o prog prog.cc -I../intl ${INTLLIBS} \
+  || exit 1
+
+tmpfiles="$tmpfiles prog.pot"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} -o prog.pot --omit-header --no-location -k_ prog.cc
+
+tmpfiles="$tmpfiles prog.ok"
+cat <<EOF > prog.ok
+msgid "'Your command, please?', asked the waiter."
+msgstr ""
+
+msgid "a piece of cake"
+msgid_plural "%d pieces of cake"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format
+msgid "%s is replaced by %s."
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} prog.ok prog.pot || exit 1
+
+tmpfiles="$tmpfiles fr.po"
+cat <<\EOF > fr.po
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+msgid "'Your command, please?', asked the waiter."
+msgstr "«Votre commande, s'il vous plait», dit le garçon."
+
+# Les gateaux allemands sont les meilleurs du monde.
+msgid "a piece of cake"
+msgid_plural "%d pieces of cake"
+msgstr[0] "un morceau de gateau"
+msgstr[1] "%d morceaux de gateau"
+
+# Reverse the arguments.
+#, c-format
+msgid "%s is replaced by %s."
+msgstr "%2$s remplace %1$s."
+EOF
+
+tmpfiles="$tmpfiles fr.po.new"
+: ${MSGMERGE=msgmerge}
+${MSGMERGE} -q -o fr.po.new fr.po prog.pot
+
+: ${DIFF=diff}
+${DIFF} fr.po fr.po.new || exit 1
+
+tmpfiles="$tmpfiles fr"
+test -d fr || mkdir fr
+test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
+
+: ${MSGFMT=msgfmt}
+${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
+
+tmpfiles="$tmpfiles prog.ok prog.out"
+: ${DIFF=diff}
+cat <<\EOF > prog.ok
+«Votre commande, s'il vous plait», dit le garçon.
+2 morceaux de gateau
+EUR remplace FF.
+EOF
+
+LANGUAGE= LC_ALL=fr_FR ./prog 2 > prog.out
+case $? in
+  0) ;;
+  77) echo "SKIP: lang-c"; exit 77;;
+  *) exit 1;;
+esac
+${DIFF} prog.ok prog.out || exit 1
+
+rm -fr $tmpfiles
+
+exit 0
diff --git a/tests/lang-java b/tests/lang-java
new file mode 100755 (executable)
index 0000000..29ab543
--- /dev/null
@@ -0,0 +1,103 @@
+#! /bin/sh
+
+# Test of gettext facilities in the Java language.
+# Assumes an fr_FR locale is installed.
+# Assumes the following packages are installed: java.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+# Test whether we can build and test Java programs.
+test "${TESTJAVA}" = yes || { echo "SKIP: lang-java"; exit 77; }
+
+tmpfiles="$tmpfiles Program.java"
+cat <<\EOF > Program.java
+import java.util.*;
+import java.text.*;
+import gnu.gettext.*;
+
+public class Program {
+  public static void main (String[] args) {
+    int n = Integer.parseInt(args[0]);
+    ResourceBundle catalog = ResourceBundle.getBundle("prog");
+    System.out.println(GettextResource.gettext(catalog,"'Your command, please?', asked the waiter."));
+    System.out.println(MessageFormat.format(GettextResource.ngettext(catalog,"a piece of cake","{0,number} pieces of cake",n), new Object[] { new Integer(n) }));
+    System.out.println(MessageFormat.format(GettextResource.gettext(catalog,"{0} is replaced by {1}."), new Object[] { "FF", "EUR" }));
+  }
+}
+EOF
+
+tmpfiles="$tmpfiles Program.class"
+: ${JAVACOMP="/bin/sh ../lib/javacomp.sh"}
+CLASSPATH=../intl-java/libintl.jar ${JAVACOMP} -d . Program.java || exit 1
+
+tmpfiles="$tmpfiles prog.pot"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} -o prog.pot Program.java
+
+tmpfiles="$tmpfiles prog.ok"
+cat <<EOF > prog.ok
+msgid "'Your command, please?', asked the waiter."
+msgstr ""
+
+msgid "a piece of cake"
+msgid_plural "{0,number} pieces of cake"
+msgstr[0] ""
+msgstr[1] ""
+
+#, java-format
+msgid "{0} is replaced by {1}."
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} prog.ok prog.pot || exit 1
+
+tmpfiles="$tmpfiles fr.po"
+cat <<\EOF > fr.po
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+msgid "'Your command, please?', asked the waiter."
+msgstr "«Votre commande, s'il vous plait», dit le garçon."
+
+# Les gateaux allemands sont les meilleurs du monde.
+msgid "a piece of cake"
+msgid_plural "{0,number} pieces of cake"
+msgstr[0] "un morceau de gateau"
+msgstr[1] "{0,number} morceaux de gateau"
+
+# Reverse the arguments.
+#, java-format
+msgid "{0} is replaced by {1}."
+msgstr "{1} remplace {0}."
+EOF
+
+tmpfiles="$tmpfiles fr.po.new"
+: ${MSGMERGE=msgmerge}
+${MSGMERGE} -q -o fr.po.new fr.po prog.pot
+
+: ${DIFF=diff}
+${DIFF} fr.po fr.po.new || exit 1
+
+tmpfiles="$tmpfiles prog_fr.class"
+: ${MSGFMT=msgfmt}
+${MSGFMT} -j -d . -r prog -l fr fr.po
+
+tmpfiles="$tmpfiles prog.ok prog.out"
+: ${DIFF=diff}
+cat <<\EOF > prog.ok
+«Votre commande, s'il vous plait», dit le garçon.
+2 morceaux de gateau
+EUR remplace FF.
+EOF
+
+: ${JAVAEXEC="/bin/sh ../lib/javaexec.sh"}
+LANGUAGE= LC_ALL=fr_FR CLASSPATH=.:../intl-java/libintl.jar ${JAVAEXEC} Program 2 > prog.out || exit 1
+${DIFF} prog.ok prog.out || exit 1
+
+rm -fr $tmpfiles
+
+exit 0
diff --git a/tests/lang-objc b/tests/lang-objc
new file mode 100755 (executable)
index 0000000..60c120d
--- /dev/null
@@ -0,0 +1,138 @@
+#! /bin/sh
+
+# Test of gettext facilities in the Objective C language.
+# Assumes an fr_FR locale is installed.
+# Assumes the following packages are installed: gcc.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+# Test whether an ObjectiveC compiler is found.
+tmpfiles="$tmpfiles hello.m hello.${OBJEXT} hello${EXEEXT}"
+cat <<\EOF > hello.m
+#include <stdio.h>
+#include <stdlib.h>
+int main ()
+{
+  printf ("Hello world\n");
+  exit (0);
+}
+EOF
+${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o hello hello.m \
+  || { echo "SKIP: lang-objc"; exit 77; }
+
+tmpfiles="$tmpfiles prog.m"
+cat <<\EOF > prog.m
+#include <libintl.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#define _(string) gettext (string)
+
+int main (argc, argv)
+  int argc;
+  char *argv[];
+{
+  int n = atoi (argv[1]);
+
+  if (setlocale (LC_ALL, "") == NULL)
+    {
+      fprintf (stderr, "Couldn't set locale.\n");
+      exit (1);
+    }
+
+  textdomain ("prog");
+  bindtextdomain ("prog", ".");
+
+  printf (_("'Your command, please?', asked the waiter."));
+  printf ("\n");
+
+  printf (ngettext ("a piece of cake", "%d pieces of cake", n), n);
+  printf ("\n");
+
+  printf (_("%s is replaced by %s."), "FF", "EUR");
+  printf ("\n");
+
+  exit (0);
+}
+EOF
+
+# Variable needed by INTLLIBS.
+top_builddir=..
+
+tmpfiles="$tmpfiles prog.${OBJEXT} prog${EXEEXT}"
+${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o prog prog.m -I../intl ${INTLLIBS} \
+  || exit 1
+
+tmpfiles="$tmpfiles prog.pot"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} -o prog.pot --omit-header --no-location -k_ prog.m
+
+tmpfiles="$tmpfiles prog.ok"
+cat <<EOF > prog.ok
+msgid "'Your command, please?', asked the waiter."
+msgstr ""
+
+msgid "a piece of cake"
+msgid_plural "%d pieces of cake"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format
+msgid "%s is replaced by %s."
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} prog.ok prog.pot || exit 1
+
+tmpfiles="$tmpfiles fr.po"
+cat <<\EOF > fr.po
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+msgid "'Your command, please?', asked the waiter."
+msgstr "«Votre commande, s'il vous plait», dit le garçon."
+
+# Les gateaux allemands sont les meilleurs du monde.
+msgid "a piece of cake"
+msgid_plural "%d pieces of cake"
+msgstr[0] "un morceau de gateau"
+msgstr[1] "%d morceaux de gateau"
+
+# Reverse the arguments.
+#, c-format
+msgid "%s is replaced by %s."
+msgstr "%2$s remplace %1$s."
+EOF
+
+tmpfiles="$tmpfiles fr.po.new"
+: ${MSGMERGE=msgmerge}
+${MSGMERGE} -q -o fr.po.new fr.po prog.pot
+
+: ${DIFF=diff}
+${DIFF} fr.po fr.po.new || exit 1
+
+tmpfiles="$tmpfiles fr"
+test -d fr || mkdir fr
+test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
+
+: ${MSGFMT=msgfmt}
+${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
+
+tmpfiles="$tmpfiles prog.ok prog.out"
+: ${DIFF=diff}
+cat <<\EOF > prog.ok
+«Votre commande, s'il vous plait», dit le garçon.
+2 morceaux de gateau
+EUR remplace FF.
+EOF
+
+LANGUAGE= LC_ALL=fr_FR ./prog 2 > prog.out || exit 1
+${DIFF} prog.ok prog.out || exit 1
+
+rm -fr $tmpfiles
+
+exit 0
diff --git a/tests/lang-pascal b/tests/lang-pascal
new file mode 100755 (executable)
index 0000000..0b4b1eb
--- /dev/null
@@ -0,0 +1,95 @@
+#! /bin/sh
+
+# Test of gettext facilities in the Object Pascal language.
+# Assumes the following packages are installed: fpk.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+# Test whether a Pascal compiler is found.
+type ppc386 >/dev/null 2>&1 || { echo "SKIP: lang-pascal"; exit 77; }
+
+tmpfiles="$tmpfiles prog.pp"
+cat <<\EOF > prog.pp
+program prog;
+{$mode delphi}
+
+uses gettext, sysutils;
+
+resourcestring
+  question = '''Your command, please?'', asked the waiter.';
+  currencies = '%s is replaced by %s.';
+
+begin
+  translateresourcestrings('%s/LC_MESSAGES/prog.mo');
+  writeln(question);
+  writeln(format(currencies, ['FF', 'EUR']));
+end.
+EOF
+
+tmpfiles="$tmpfiles prog.o prog.rst prog"
+ppc386 prog.pp || exit 1
+
+tmpfiles="$tmpfiles prog.pot"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} -o prog.pot --omit-header --add-location prog.rst
+
+tmpfiles="$tmpfiles prog.ok"
+cat <<EOF > prog.ok
+#: prog.question
+msgid "'Your command, please?', asked the waiter."
+msgstr ""
+
+#: prog.currencies
+#, object-pascal-format
+msgid "%s is replaced by %s."
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} prog.ok prog.pot || exit 1
+
+tmpfiles="$tmpfiles fr.po"
+cat <<\EOF > fr.po
+msgid ""
+msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"
+
+#: prog.question
+msgid "'Your command, please?', asked the waiter."
+msgstr "«Votre commande, s'il vous plait», dit le garçon."
+
+# Reverse the arguments.
+#: prog.currencies
+#, object-pascal-format
+msgid "%s is replaced by %s."
+msgstr "%1:s remplace %0:s."
+EOF
+
+tmpfiles="$tmpfiles fr.po.new"
+: ${MSGMERGE=msgmerge}
+${MSGMERGE} -q -o fr.po.new fr.po prog.pot
+
+: ${DIFF=diff}
+${DIFF} fr.po fr.po.new || exit 1
+
+tmpfiles="$tmpfiles fr"
+test -d fr || mkdir fr
+test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
+
+: ${MSGFMT=msgfmt}
+${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
+
+tmpfiles="$tmpfiles prog.ok prog.out"
+: ${DIFF=diff}
+cat <<\EOF > prog.ok
+«Votre commande, s'il vous plait», dit le garçon.
+EUR remplace FF.
+EOF
+
+LANGUAGE= LC_ALL= LC_MESSAGES= LC_CTYPE= LANG=fr_FR ./prog > prog.out || exit 1
+: ${DIFF=diff}
+${DIFF} prog.ok prog.out || exit 1
+
+rm -fr $tmpfiles
+
+exit 0
diff --git a/tests/lang-po b/tests/lang-po
new file mode 100755 (executable)
index 0000000..32bc28c
--- /dev/null
@@ -0,0 +1,65 @@
+#! /bin/sh
+
+# Test of gettext facilities in the PO/POT format.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+# Test with POT format.
+
+tmpfiles="$tmpfiles prog-in.pot"
+cat <<\EOF > prog-in.pot
+msgid "'Your command, please?', asked the waiter."
+msgstr ""
+
+msgid "a piece of cake"
+msgid_plural "%d pieces of cake"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format
+msgid "%s is replaced by %s."
+msgstr ""
+EOF
+
+tmpfiles="$tmpfiles prog.pot"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} -o prog.pot --omit-header --add-location prog-in.pot
+
+: ${DIFF=diff}
+${DIFF} prog-in.pot prog.pot || exit 1
+
+# Test with PO format.
+
+tmpfiles="$tmpfiles prog-in.po"
+cat <<\EOF > prog-in.po
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+msgid "'Your command, please?', asked the waiter."
+msgstr "«Votre commande, s'il vous plait», dit le garçon."
+
+# Les gateaux allemands sont les meilleurs du monde.
+msgid "a piece of cake"
+msgid_plural "%d pieces of cake"
+msgstr[0] "un morceau de gateau"
+msgstr[1] "%d morceaux de gateau"
+
+# Reverse the arguments.
+#, c-format
+msgid "%s is replaced by %s."
+msgstr "%2$s remplace %1$s."
+EOF
+
+tmpfiles="$tmpfiles prog.po"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} -o prog.po --omit-header --add-location prog-in.po
+
+: ${DIFF=diff}
+${DIFF} prog-in.po prog.po || exit 1
+
+rm -fr $tmpfiles
+
+exit 0
diff --git a/tests/lang-rst b/tests/lang-rst
new file mode 100755 (executable)
index 0000000..be48466
--- /dev/null
@@ -0,0 +1,105 @@
+#! /bin/sh
+
+# Test of gettext facilities in the RST format.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles prog.rst"
+cat <<\EOF > prog.rst
+# From the rstconv program itself.
+rstconv.help='rstconv [-h|--help]    Displays this help'#10+
+'rstconv options        Convert rst file'#10#10+
+'Options are:'#10+
+'  -i file    Use specified file instead of stdin as input .rst (OPTIONAL)'#10+
+'  -o file    Write output to specified file (REQUIRED)'#10+
+'  -f format  Specifies the output format:'#10+
+'             po    GNU gettext .po (portable) format (DEFAULT)'#10
+
+rstconv.InvalidOption='Invalid option - '
+rstconv.OptionAlreadySpecified='Option has already been specified - '
+rstconv.NoOutFilename='No output filename specified'
+rstconv.InvalidOutputFormat='Invalid output format -'
+EOF
+
+tmpfiles="$tmpfiles prog.pot"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} -o prog.pot --omit-header --add-location prog.rst
+
+tmpfiles="$tmpfiles prog.ok"
+cat <<EOF > prog.ok
+#: rstconv.help
+msgid ""
+"rstconv [-h|--help]    Displays this help\n"
+"rstconv options        Convert rst file\n"
+"\n"
+"Options are:\n"
+"  -i file    Use specified file instead of stdin as input .rst (OPTIONAL)\n"
+"  -o file    Write output to specified file (REQUIRED)\n"
+"  -f format  Specifies the output format:\n"
+"             po    GNU gettext .po (portable) format (DEFAULT)\n"
+msgstr ""
+
+#: rstconv.InvalidOption
+msgid "Invalid option - "
+msgstr ""
+
+#: rstconv.OptionAlreadySpecified
+msgid "Option has already been specified - "
+msgstr ""
+
+#: rstconv.NoOutFilename
+msgid "No output filename specified"
+msgstr ""
+
+#: rstconv.InvalidOutputFormat
+msgid "Invalid output format -"
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} prog.ok prog.pot || exit 1
+
+# The output of rstconv is slightly different:
+# - ModuleName:ConstName instead of ModuleName.ConstName
+# - no line wrapping
+# - extra newline at the end
+
+: ${RSTCONV=rstconv}
+if type ${RSTCONV} >/dev/null 2>&1; then
+
+tmpfiles="$tmpfiles prog.pot"
+${RSTCONV} -o prog.pot -i prog.rst
+
+tmpfiles="$tmpfiles prog.ok"
+cat <<EOF > prog.ok
+#: rstconv:help
+msgid "rstconv [-h|--help]    Displays this help\nrstconv options        Convert rst file\n\nOptions are:\n  -i file    Use specified file instead of stdin as input .rst (OPTIONAL)\n  -o file    Write output to specified file (REQUIRED)\n  -f format  Specifies the output format:\n             po    GNU gettext .po (portable) format (DEFAULT)\n"
+msgstr ""
+
+#: rstconv:InvalidOption
+msgid "Invalid option - "
+msgstr ""
+
+#: rstconv:OptionAlreadySpecified
+msgid "Option has already been specified - "
+msgstr ""
+
+#: rstconv:NoOutFilename
+msgid "No output filename specified"
+msgstr ""
+
+#: rstconv:InvalidOutputFormat
+msgid "Invalid output format -"
+msgstr ""
+
+EOF
+
+: ${DIFF=diff}
+${DIFF} prog.ok prog.pot || exit 1
+
+fi
+
+rm -fr $tmpfiles
+
+exit 0
diff --git a/tests/lang-ycp b/tests/lang-ycp
new file mode 100755 (executable)
index 0000000..d5275bc
--- /dev/null
@@ -0,0 +1,72 @@
+#! /bin/sh
+
+# Test of gettext facilities in the YCP language.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles prog.ycp"
+cat <<\EOF > prog.ycp
+{
+  textdomain "prog";
+
+  print (_("'Your command, please?', asked the waiter."));
+  print (sformat (_("a piece of cake", "%1 pieces of cake", n), n));
+  print (sformat (_("%1 is replaced by %2."), "FF", "EUR"));
+}
+EOF
+
+tmpfiles="$tmpfiles prog.pot"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} -o prog.pot --omit-header --no-location prog.ycp
+
+tmpfiles="$tmpfiles prog.ok"
+cat <<EOF > prog.ok
+msgid "'Your command, please?', asked the waiter."
+msgstr ""
+
+msgid "a piece of cake"
+msgid_plural "%1 pieces of cake"
+msgstr[0] ""
+msgstr[1] ""
+
+#, ycp-format
+msgid "%1 is replaced by %2."
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} prog.ok prog.pot || exit 1
+
+tmpfiles="$tmpfiles fr.po"
+cat <<\EOF > fr.po
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+msgid "'Your command, please?', asked the waiter."
+msgstr "«Votre commande, s'il vous plait», dit le garçon."
+
+# Les gateaux allemands sont les meilleurs du monde.
+msgid "a piece of cake"
+msgid_plural "%1 pieces of cake"
+msgstr[0] "un morceau de gateau"
+msgstr[1] "%1 morceaux de gateau"
+
+# Reverse the arguments.
+#, ycp-format
+msgid "%1 is replaced by %2."
+msgstr "%2 remplace %1."
+EOF
+
+tmpfiles="$tmpfiles fr.po.new"
+: ${MSGMERGE=msgmerge}
+${MSGMERGE} -q -o fr.po.new fr.po prog.pot
+
+: ${DIFF=diff}
+${DIFF} fr.po fr.po.new || exit 1
+
+rm -fr $tmpfiles
+
+exit 0