[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gawk: use of HAVE_LC_MESSAGES
From: |
Bruno Haible |
Subject: |
gawk: use of HAVE_LC_MESSAGES |
Date: |
Tue, 28 Nov 2006 21:45:19 +0100 |
User-agent: |
KMail/1.9.1 |
Hello Arnold,
GNU gettext has in its test suite a test that checks whether gawk's
internationalization is working fine (file gettext-tools/tests/lang-gawk).
It uses a simple program like this:
============================================================================
BEGIN {
TEXTDOMAIN = "prog"
bindtextdomain ("./")
print _"'Your command, please?', asked the waiter."
printf dcngettext ("a piece of cake", "%d pieces of cake", n) "\n", n
printf _"%s is replaced by %s." "\n", "FF", "EUR"
}
============================================================================
Ralf Menzel reports a failure of this test on Solaris 9 with gawk 3.1.5,
see http://lists.gnu.org/archive/html/bug-gnu-utils/2006-11/msg00140.html
It appears that _ produces localized output but dcngettext doesn't. Ralf
has completed the analysis:
I fetched gawk-stable from savannah and compiled it.
Unfortunately, the failure remained. I then started to try to
understand what might be happening.
In builtin.c there is a function do_dcngettext that is responsible for
calling dcngettext. But when either of the preprocessor macros
ENABLE_NLS, HAVE_LC_MESSAGES, or HAVE_DCGETTEXT is not true, it
instead contains a very simple replacement for dcngettext. I found the
on my computer HAVE_LC_MESSAGES is not set. (It's not mentioned in
config.h or even in configh.in.) After some experimentation I arrived
at the following patch that shows the problem:
--- snip ---
diff -u -p -r1.2 configure.ac
--- gawk-stable/configure.ac 11 Aug 2006 12:49:40 -0000 1.2
+++ gawk-stable/configure.ac 28 Nov 2006 17:48:43 -0000
@@ -140,6 +140,7 @@ esac
dnl initialize GNU gettext
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.14.4])
+gt_LC_MESSAGES
dnl checks for header files
AC_HEADER_STDC
--- snip ---
With this patch I could build a version of awk that passes the
lang-gawk test of gettext-0.16.
While this patch fixes the problem for Solaris, which has LC_MESSAGES, it
will not do so for mingw, which doesn't have LC_MESSAGES. On such platforms,
it's <libintl.h> from GNU gettext (included from gettext.h, included from
awk.h) which will define LC_MESSAGES. But HAVE_LC_MESSAGES will not be defined
on such a platform. So what I propose instead of Ralf's patch is this one:
--- builtin.c 11 Aug 2006 12:49:39 -0000 1.2
+++ builtin.c 28 Nov 2006 20:42:03 -0000
@@ -3014,7 +3014,7 @@
/* do_dcgettext, do_dcngettext --- handle i18n translations */
-#if ENABLE_NLS && HAVE_LC_MESSAGES && HAVE_DCGETTEXT
+#if ENABLE_NLS && defined LC_MESSAGES && HAVE_DCGETTEXT
static int
localecategory_from_argument(NODE *tree)
This enables the localecategory_from_argument function also for platforms
like mingw.
Bruno
- gawk: use of HAVE_LC_MESSAGES,
Bruno Haible <=