glib gettext implementation



Ok, due to poplar demand (i wanted it) i finished the glib gettext 
implementation. This version is basically the same as the old one, with 
the get_locale() function updated and with the m4 macros updated to make 
the build work correctly.

With this patch applied the gettext status for glib is:

* glib always contains a gettext runtime implementation (unless 
--disable-nls is specified). All apps should just include glib/gintlh, and 
need not look for libintl.h or -lintl.

* If glib doesn't find a gettext implementation in libc or libint it will 
use the built in version. If you want to force usage of the built in 
version use --with-included-gettext

* The macro AM_GLIB_GNU_GETTEXT in glib-gettext.m4 can still be used as 
before. Now it only takes care of locating the gettext utilities for 
generating .mo files and the building of the po directory. It no longer 
locates libintl.h or -lintl.

* Apps should use g_gettext() & co instead of gettext(). If the libc or 
libintl implementation is used these are only defines, so no performance 
is lost.

* I haven't actually built this under win32 yet, but it should work. This 
means that we have a clean LGPL gettext implementation the win32 port can 
use and that we can distribute.

/ Alex

Here are patches for glib and gtk+:

Index: acinclude.m4
===================================================================
RCS file: /cvs/gnome/glib/acinclude.m4,v
retrieving revision 1.9
diff -u -p -r1.9 acinclude.m4
--- acinclude.m4	2001/05/16 18:35:36	1.9
+++ acinclude.m4	2001/08/22 05:35:51
@@ -19,38 +19,21 @@
 
 # serial 5
 
-AC_DEFUN(AM_GLIB_WITH_NLS,
-  [AC_MSG_CHECKING([whether NLS is requested])
-    dnl Default is enabled NLS
-    AC_ARG_ENABLE(nls,
-      [  --disable-nls           do not use Native Language Support],
-      USE_NLS=$enableval, USE_NLS=yes)
-    AC_MSG_RESULT($USE_NLS)
-    AC_SUBST(USE_NLS)
+AC_DEFUN(AM_GLIB_GETTEXT,
+  [
+      AC_MSG_CHECKING([whether included gettext is requested])
+      AC_ARG_WITH(included-gettext,
+        [  --with-included-gettext use the glib gettext implementation],
+        nls_cv_force_use_glib_gettext=$withval,
+        nls_cv_force_use_glib_gettext=no)
+      AC_MSG_RESULT($nls_cv_force_use_glib_gettext)
+
+      nls_cv_use_glib_gettext="$nls_cv_force_use_glib_gettext"
+      if test "$nls_cv_force_use_glib_gettext" != "yes"; then
+        dnl User does not insist on using the glib gettext implementation.
+	dnl Figure out what to use.  If gettext is available we
+        dnl use this.  Else we have to fall back to the glib implementation.
 
-    USE_INCLUDED_LIBINTL=no
-
-    dnl If we use NLS figure out what method
-    if test "$USE_NLS" = "yes"; then
-#      AC_DEFINE(ENABLE_NLS)
-#      AC_MSG_CHECKING([whether included gettext is requested])
-#      AC_ARG_WITH(included-gettext,
-#        [  --with-included-gettext use the GNU gettext library included here],
-#        nls_cv_force_use_gnu_gettext=$withval,
-#        nls_cv_force_use_gnu_gettext=no)
-#      AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
-      nls_cv_force_use_gnu_gettext="no"
-
-      nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
-      if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
-        dnl User does not insist on using GNU NLS library.  Figure out what
-        dnl to use.  If gettext or catgets are available (in this order) we
-        dnl use this.  Else we have to fall back to GNU NLS library.
-	dnl catgets is only used if permitted by option --with-catgets.
-	nls_cv_header_intl=
-	nls_cv_header_libgt=
-	CATOBJEXT=NONE
-
 	AC_CHECK_HEADER(libintl.h,
 	  [AC_CACHE_CHECK([for dgettext in libc], gt_cv_func_dgettext_libc,
 	    [AC_TRY_LINK([#include <libintl.h>], [return (int) dgettext ("","")],
@@ -70,99 +53,72 @@ AC_DEFUN(AM_GLIB_WITH_NLS,
 	     LIBS="$LIBS -lintl";
            fi
 
+	   # Added by Martin Baulig 12/15/98 for libc5 systems
+	   if test "$gt_cv_func_dgettext_libc" != "yes" \
+	      && test "$gt_cv_func_dgettext_libintl" = "yes"; then
+	     INTLLIBS=-lintl
+	     LIBS=`echo $LIBS | sed -e 's/-lintl//'`
+	   fi
+
 	   if test "$gt_cv_func_dgettext_libc" = "yes" \
 	      || test "$gt_cv_func_dgettext_libintl" = "yes"; then
-	      AC_DEFINE(HAVE_GETTEXT)
-	      AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
-		[test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
-	      if test "$MSGFMT" != "no"; then
-		AC_CHECK_FUNCS(dcgettext)
-		AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
-		AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
-		  [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
-		AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
-			       return _nl_msg_cat_cntr],
-		  [CATOBJEXT=.gmo
-		   DATADIRNAME=share],
-		  [CATOBJEXT=.mo
-		   DATADIRNAME=lib])
-		INSTOBJEXT=.mo
-	      fi
-	    fi
-
-	    # Added by Martin Baulig 12/15/98 for libc5 systems
-	    if test "$gt_cv_func_dgettext_libc" != "yes" \
-	       && test "$gt_cv_func_dgettext_libintl" = "yes"; then
-	       INTLLIBS=-lintl
-	       LIBS=`echo $LIBS | sed -e 's/-lintl//'`
-	    fi
+	     AC_DEFINE(HAVE_GETTEXT)
+	     AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
+	       [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
+	     if test "$MSGFMT" != "no"; then
+	       AC_CHECK_FUNCS(dcgettext)
+	     fi
+	   else
+	     dnl fallback on the glib gettext implementation
+	     nls_cv_use_glib_gettext="yes"
+	   fi
+	
+
 	])
+    fi
+
+    glib_have_libintl_h=yes;
+    if test "$nls_cv_use_glib_gettext" = "yes"; then
+      # set the use builtin gettext config option
+      glib_have_libintl_h=no;
+    fi
+  ])
+
 
-#        if test "$CATOBJEXT" = "NONE"; then
-#	  AC_MSG_CHECKING([whether catgets can be used])
-#	  AC_ARG_WITH(catgets,
-#	    [  --with-catgets          use catgets functions if available],
-#	    nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
-#	  AC_MSG_RESULT($nls_cv_use_catgets)
-#
-#	  if test "$nls_cv_use_catgets" = "yes"; then
-#	    dnl No gettext in C library.  Try catgets next.
-#	    AC_CHECK_LIB(i, main)
-#	    AC_CHECK_FUNC(catgets,
-#	      [AC_DEFINE(HAVE_CATGETS)
-#	       INTLOBJS="\$(CATOBJS)"
-#	       AC_PATH_PROG(GENCAT, gencat, no)dnl
-#	       if test "$GENCAT" != "no"; then
-#		 AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
-#		 if test "$GMSGFMT" = "no"; then
-#		   AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
-#		    [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
-#		 fi
-#		 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
-#		   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
-#		 USE_INCLUDED_LIBINTL=yes
-#		 CATOBJEXT=.cat
-#		 INSTOBJEXT=.cat
-#		 DATADIRNAME=lib
-#		 INTLDEPS='$(top_builddir)/intl/libintl.a'
-#		 INTLLIBS=$INTLDEPS
-#		 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
-#		 nls_cv_header_intl=intl/libintl.h
-#		 nls_cv_header_libgt=intl/libgettext.h
-#              fi
-#            ])
-#	  fi
-#        fi
-
-        if test "$CATOBJEXT" = "NONE"; then
-	  dnl Neither gettext nor catgets in included in the C library.
-	  dnl Fall back on GNU gettext library.
-	  nls_cv_use_gnu_gettext=yes
-        fi
+AC_DEFUN(AM_GLIB_WITH_NLS,
+  [AC_MSG_CHECKING([whether NLS is requested])
+    dnl Default is enabled NLS
+    AC_ARG_ENABLE(nls,
+      [  --disable-nls           do not use Native Language Support],
+      USE_NLS=$enableval, USE_NLS=yes)
+    AC_MSG_RESULT($USE_NLS)
+    AC_SUBST(USE_NLS)
+
+    dnl If we use NLS figure out what method
+    if test "$USE_NLS" = "yes"; then
+      AC_DEFINE(ENABLE_NLS)
+      CATOBJEXT=NONE
+      AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
+	[test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
+      if test "$MSGFMT" != "no"; then
+	AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
+	AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
+	  [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
+	AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
+		       return _nl_msg_cat_cntr],
+	  [CATOBJEXT=.gmo
+	   DATADIRNAME=share],
+	  [CATOBJEXT=.mo
+	   DATADIRNAME=lib])
+	INSTOBJEXT=.mo
       fi
 
-      if test "$nls_cv_use_gnu_gettext" != "yes"; then
-        AC_DEFINE(ENABLE_NLS)
-      else
-         dnl Unset this variable since we use the non-zero value as a flag.
-         CATOBJEXT=
-#        dnl Mark actions used to generate GNU NLS library.
-#        INTLOBJS="\$(GETTOBJS)"
-#        AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
-#	  [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
-#        AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
-#        AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
-#	  [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
-#        AC_SUBST(MSGFMT)
-#	USE_INCLUDED_LIBINTL=yes
-#        CATOBJEXT=.gmo
-#        INSTOBJEXT=.mo
-#        DATADIRNAME=share
-#	INTLDEPS='$(top_builddir)/intl/libintl.a'
-#	INTLLIBS=$INTLDEPS
-#	LIBS=`echo $LIBS | sed -e 's/-lintl//'`
-#        nls_cv_header_intl=intl/libintl.h
-#        nls_cv_header_libgt=intl/libgettext.h
+      if test "$CATOBJEXT" = "NONE"; then
+	dnl Didn't find gettext, use the included gnu
+	dnl catalogs.
+	CATOBJEXT=.gmo
+        INSTOBJEXT=.mo
+        DATADIRNAME=share
       fi
 
       dnl Test whether we really found GNU xgettext.
@@ -182,23 +138,13 @@ AC_DEFUN(AM_GLIB_WITH_NLS,
       POSUB=po
     else
       DATADIRNAME=share
-#      nls_cv_header_intl=intl/libintl.h
-#      nls_cv_header_libgt=intl/libgettext.h
     fi
-#    AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
+
     AC_OUTPUT_COMMANDS(
      [case "$CONFIG_FILES" in *po/Makefile.in*)
         sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
       esac])
 
-
-#    # If this is used in GNU gettext we have to set USE_NLS to `yes'
-#    # because some of the sources are only built for this goal.
-#    if test "$PACKAGE" = gettext; then
-#      USE_NLS=yes
-#      USE_INCLUDED_LIBINTL=yes
-#    fi
-
     dnl These rules are solely for the distribution goal.  While doing this
     dnl we only have to keep exactly one list of the available catalogs
     dnl in configure.in.
@@ -208,7 +154,6 @@ AC_DEFUN(AM_GLIB_WITH_NLS,
     done
 
     dnl Make all variables we use known to autoconf.
-    AC_SUBST(USE_INCLUDED_LIBINTL)
     AC_SUBST(CATALOGS)
     AC_SUBST(CATOBJEXT)
     AC_SUBST(DATADIRNAME)
@@ -239,13 +184,6 @@ unistd.h sys/param.h])
    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
 strdup __argz_count __argz_stringify __argz_next])
 
-#   if test "${ac_cv_func_stpcpy+set}" != "set"; then
-#     AC_CHECK_FUNCS(stpcpy)
-#   fi
-#   if test "${ac_cv_func_stpcpy}" = "yes"; then
-#     AC_DEFINE(HAVE_STPCPY)
-#   fi
-
    AM_LC_MESSAGES
    AM_GLIB_WITH_NLS
 
@@ -270,17 +208,6 @@ strdup __argz_count __argz_stringify __a
      fi
    fi
 
-#   dnl The reference to <locale.h> in the installed <libintl.h> file
-#   dnl must be resolved because we cannot expect the users of this
-#   dnl to define HAVE_LOCALE_H.
-#   if test $ac_cv_header_locale_h = yes; then
-#     INCLUDE_LOCALE_H="#include <locale.h>"
-#   else
-#     INCLUDE_LOCALE_H="\
-#/* The system does not provide the header <locale.h>.  Take care yourself.  */"
-#   fi
-#   AC_SUBST(INCLUDE_LOCALE_H)
-
    dnl Determine which catalog format we have (if any is needed)
    dnl For now we know about two different formats:
    dnl   Linux libc-5 and the normal X/Open format
@@ -295,19 +222,6 @@ strdup __argz_count __argz_stringify __a
    dnl po2tbl.sed is always needed.
    sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
      $srcdir/po/po2tbl.sed.in > po/po2tbl.sed
-
-#   dnl In the intl/Makefile.in we have a special dependency which makes
-#   dnl only sense for gettext.  We comment this out for non-gettext
-#   dnl packages.
-#   if test "$PACKAGE" = "gettext"; then
-#     GT_NO="#NO#"
-#     GT_YES=
-#   else
-#     GT_NO=
-#     GT_YES="#YES#"
-#   fi
-#   AC_SUBST(GT_NO)
-#   AC_SUBST(GT_YES)
 
    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
    dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
Index: configure.in
===================================================================
RCS file: /cvs/gnome/glib/configure.in,v
retrieving revision 1.217
diff -u -p -r1.217 configure.in
--- configure.in	2001/08/21 05:10:33	1.217
+++ configure.in	2001/08/22 05:35:51
@@ -201,6 +201,9 @@ dnl gettext support
 dnl
 
 ALL_LINGUAS="az ca de eu fr nn no ru sl sv ta tr uk zh_TW"
+AM_GLIB_GETTEXT
+AC_CACHE_VAL(glib_cv_have_libintl_h,
+	glib_cv_have_libintl_h=$glib_have_libintl_h)
 AM_GLIB_GNU_GETTEXT
 LIBS="$LIBS $INTLLIBS"
 
@@ -1555,6 +1558,9 @@ _______EOF
 	if test x$glib_sys_poll_h = xyes; then
 	  echo '#define GLIB_HAVE_SYS_POLL_H' >> $outfile
 	fi
+	if test x$glib_have_libintl_h = xyes; then
+	  echo '#define GLIB_HAVE_LIBINTL_H' >> $outfile
+	fi
 
 	cat >> $outfile <<_______EOF
 
@@ -1838,6 +1844,10 @@ x$ac_cv_header_values_h)
   glib_ml=MINLONG  glib_Ml=MAXLONG  glib_Mul="(((gulong)G_MAXLONG)*2+1)"
   ;;
 esac
+
+if test x$glib_cv_have_libintl_h = xyes ; then
+  glib_have_libintl_h=yes
+fi
 
 if test x$ac_cv_header_sys_poll_h = xyes ; then
   glib_sys_poll_h=yes
Index: glib/Makefile.am
===================================================================
RCS file: /cvs/gnome/glib/glib/Makefile.am,v
retrieving revision 1.89
diff -u -p -r1.89 Makefile.am
--- glib/Makefile.am	2001/07/23 11:44:04	1.89
+++ glib/Makefile.am	2001/08/22 05:35:52
@@ -22,6 +22,7 @@ libglib_1_3_la_SOURCES = 	\
 	gfileutils.c		\
 	ghash.c			\
 	ghook.c			\
+	gintl.c			\
 	giochannel.c    	\
 	glibintl.h		\
 	glist.c			\
@@ -83,6 +84,7 @@ glibsubinclude_HEADERS =   \
 	gfileutils.h	\
 	ghash.h		\
 	ghook.h		\
+	gintl.h		\
 	giochannel.h	\
 	glist.h		\
 	gmacros.h	\
Index: glib/glib.h
===================================================================
RCS file: /cvs/gnome/glib/glib/glib.h,v
retrieving revision 1.217
diff -u -p -r1.217 glib.h
--- glib/glib.h	2001/06/26 16:01:14	1.217
+++ glib/glib.h	2001/08/22 05:35:52
@@ -68,6 +68,7 @@
 #include <glib/gtypes.h>
 #include <glib/gunicode.h>
 #include <glib/gutils.h>
+#include <glib/gintl.h>
 #ifdef G_PLATFORM_WIN32
 #include <glib/gwin32.h>
 #endif
Index: glib/glibintl.h
===================================================================
RCS file: /cvs/gnome/glib/glib/glibintl.h,v
retrieving revision 1.2
diff -u -p -r1.2 glibintl.h
--- glib/glibintl.h	2001/01/17 04:31:20	1.2
+++ glib/glibintl.h	2001/08/22 05:35:52
@@ -7,7 +7,7 @@
 
 gchar *_glib_gettext (const gchar *str);
 
-#include <libintl.h>
+#include "gintl.h"
 #define _(String) _glib_gettext(String)
 
 #ifdef gettext_noop
Index: glib/gutils.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gutils.c,v
retrieving revision 1.98
diff -u -p -r1.98 gutils.c
--- glib/gutils.c	2001/08/06 20:55:10	1.98
+++ glib/gutils.c	2001/08/22 05:35:52
@@ -1109,11 +1109,11 @@ _glib_gettext (const gchar *str)
 
   if (!_glib_gettext_initialized)
     {
-      bindtextdomain(GETTEXT_PACKAGE, GLIB_LOCALE_DIR);
+      g_bindtextdomain(GETTEXT_PACKAGE, GLIB_LOCALE_DIR);
       _glib_gettext_initialized = TRUE;
     }
   
-  return dgettext (GETTEXT_PACKAGE, str);
+  return g_dgettext (GETTEXT_PACKAGE, str);
 }
 
 #endif /* ENABLE_NLS */
Index: m4macros/glib-gettext.m4
===================================================================
RCS file: /cvs/gnome/glib/m4macros/glib-gettext.m4,v
retrieving revision 1.2
diff -u -p -r1.2 glib-gettext.m4
--- m4macros/glib-gettext.m4	2001/01/31 19:18:48	1.2
+++ m4macros/glib-gettext.m4	2001/08/22 05:35:53
@@ -28,141 +28,31 @@ AC_DEFUN(AM_GLIB_WITH_NLS,
     AC_MSG_RESULT($USE_NLS)
     AC_SUBST(USE_NLS)
 
-    USE_INCLUDED_LIBINTL=no
-
     dnl If we use NLS figure out what method
     if test "$USE_NLS" = "yes"; then
-#      AC_DEFINE(ENABLE_NLS)
-#      AC_MSG_CHECKING([whether included gettext is requested])
-#      AC_ARG_WITH(included-gettext,
-#        [  --with-included-gettext use the GNU gettext library included here],
-#        nls_cv_force_use_gnu_gettext=$withval,
-#        nls_cv_force_use_gnu_gettext=no)
-#      AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
-      nls_cv_force_use_gnu_gettext="no"
-
-      nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
-      if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
-        dnl User does not insist on using GNU NLS library.  Figure out what
-        dnl to use.  If gettext or catgets are available (in this order) we
-        dnl use this.  Else we have to fall back to GNU NLS library.
-	dnl catgets is only used if permitted by option --with-catgets.
-	nls_cv_header_intl=
-	nls_cv_header_libgt=
-	CATOBJEXT=NONE
-
-	AC_CHECK_HEADER(libintl.h,
-	  [AC_CACHE_CHECK([for dgettext in libc], gt_cv_func_dgettext_libc,
-	    [AC_TRY_LINK([#include <libintl.h>], [return (int) dgettext ("","")],
-	       gt_cv_func_dgettext_libc=yes, gt_cv_func_dgettext_libc=no)])
-
-	   if test "$gt_cv_func_dgettext_libc" != "yes"; then
-	     AC_CHECK_LIB(intl, bindtextdomain,
-	       [AC_CACHE_CHECK([for dgettext in libintl],
-		 gt_cv_func_dgettext_libintl,
-		 [AC_CHECK_LIB(intl, dgettext,
-		  gt_cv_func_dgettext_libintl=yes,
-		  gt_cv_func_dgettext_libintl=no)],
-		 gt_cv_func_dgettext_libintl=no)])
-	   fi
-
-           if test "$gt_cv_func_dgettext_libintl" = "yes"; then
-	     LIBS="$LIBS -lintl";
-           fi
-
-	   if test "$gt_cv_func_dgettext_libc" = "yes" \
-	      || test "$gt_cv_func_dgettext_libintl" = "yes"; then
-	      AC_DEFINE(HAVE_GETTEXT)
-	      AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
-		[test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
-	      if test "$MSGFMT" != "no"; then
-		AC_CHECK_FUNCS(dcgettext)
-		AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
-		AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
-		  [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
-		AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
-			       return _nl_msg_cat_cntr],
-		  [CATOBJEXT=.gmo
-		   DATADIRNAME=share],
-		  [CATOBJEXT=.mo
-		   DATADIRNAME=lib])
-		INSTOBJEXT=.mo
-	      fi
-	    fi
-
-	    # Added by Martin Baulig 12/15/98 for libc5 systems
-	    if test "$gt_cv_func_dgettext_libc" != "yes" \
-	       && test "$gt_cv_func_dgettext_libintl" = "yes"; then
-	       INTLLIBS=-lintl
-	       LIBS=`echo $LIBS | sed -e 's/-lintl//'`
-	    fi
-	])
-
-#        if test "$CATOBJEXT" = "NONE"; then
-#	  AC_MSG_CHECKING([whether catgets can be used])
-#	  AC_ARG_WITH(catgets,
-#	    [  --with-catgets          use catgets functions if available],
-#	    nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
-#	  AC_MSG_RESULT($nls_cv_use_catgets)
-#
-#	  if test "$nls_cv_use_catgets" = "yes"; then
-#	    dnl No gettext in C library.  Try catgets next.
-#	    AC_CHECK_LIB(i, main)
-#	    AC_CHECK_FUNC(catgets,
-#	      [AC_DEFINE(HAVE_CATGETS)
-#	       INTLOBJS="\$(CATOBJS)"
-#	       AC_PATH_PROG(GENCAT, gencat, no)dnl
-#	       if test "$GENCAT" != "no"; then
-#		 AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
-#		 if test "$GMSGFMT" = "no"; then
-#		   AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
-#		    [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
-#		 fi
-#		 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
-#		   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
-#		 USE_INCLUDED_LIBINTL=yes
-#		 CATOBJEXT=.cat
-#		 INSTOBJEXT=.cat
-#		 DATADIRNAME=lib
-#		 INTLDEPS='$(top_builddir)/intl/libintl.a'
-#		 INTLLIBS=$INTLDEPS
-#		 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
-#		 nls_cv_header_intl=intl/libintl.h
-#		 nls_cv_header_libgt=intl/libgettext.h
-#              fi
-#            ])
-#	  fi
-#        fi
-
-        if test "$CATOBJEXT" = "NONE"; then
-	  dnl Neither gettext nor catgets in included in the C library.
-	  dnl Fall back on GNU gettext library.
-	  nls_cv_use_gnu_gettext=yes
-        fi
+      AC_DEFINE(ENABLE_NLS)
+      CATOBJEXT=NONE
+      AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
+	[test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
+      if test "$MSGFMT" != "no"; then
+	AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
+	AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
+	  [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
+	AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
+		       return _nl_msg_cat_cntr],
+	  [CATOBJEXT=.gmo
+	   DATADIRNAME=share],
+	  [CATOBJEXT=.mo
+	   DATADIRNAME=lib])
+	INSTOBJEXT=.mo
       fi
 
-      if test "$nls_cv_use_gnu_gettext" != "yes"; then
-        AC_DEFINE(ENABLE_NLS)
-      else
-         dnl Unset this variable since we use the non-zero value as a flag.
-         CATOBJEXT=
-#        dnl Mark actions used to generate GNU NLS library.
-#        INTLOBJS="\$(GETTOBJS)"
-#        AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
-#	  [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
-#        AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
-#        AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
-#	  [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
-#        AC_SUBST(MSGFMT)
-#	USE_INCLUDED_LIBINTL=yes
-#        CATOBJEXT=.gmo
-#        INSTOBJEXT=.mo
-#        DATADIRNAME=share
-#	INTLDEPS='$(top_builddir)/intl/libintl.a'
-#	INTLLIBS=$INTLDEPS
-#	LIBS=`echo $LIBS | sed -e 's/-lintl//'`
-#        nls_cv_header_intl=intl/libintl.h
-#        nls_cv_header_libgt=intl/libgettext.h
+      if test "$CATOBJEXT" = "NONE"; then
+	dnl Didn't find gettext, use the included gnu
+	dnl catalogs.
+	CATOBJEXT=.gmo
+        INSTOBJEXT=.mo
+        DATADIRNAME=share
       fi
 
       dnl Test whether we really found GNU xgettext.
@@ -182,23 +72,13 @@ AC_DEFUN(AM_GLIB_WITH_NLS,
       POSUB=po
     else
       DATADIRNAME=share
-#      nls_cv_header_intl=intl/libintl.h
-#      nls_cv_header_libgt=intl/libgettext.h
     fi
-#    AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
+
     AC_OUTPUT_COMMANDS(
      [case "$CONFIG_FILES" in *po/Makefile.in*)
         sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
       esac])
 
-
-#    # If this is used in GNU gettext we have to set USE_NLS to `yes'
-#    # because some of the sources are only built for this goal.
-#    if test "$PACKAGE" = gettext; then
-#      USE_NLS=yes
-#      USE_INCLUDED_LIBINTL=yes
-#    fi
-
     dnl These rules are solely for the distribution goal.  While doing this
     dnl we only have to keep exactly one list of the available catalogs
     dnl in configure.in.
@@ -208,7 +88,6 @@ AC_DEFUN(AM_GLIB_WITH_NLS,
     done
 
     dnl Make all variables we use known to autoconf.
-    AC_SUBST(USE_INCLUDED_LIBINTL)
     AC_SUBST(CATALOGS)
     AC_SUBST(CATOBJEXT)
     AC_SUBST(DATADIRNAME)
@@ -239,13 +118,6 @@ unistd.h sys/param.h])
    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
 strdup __argz_count __argz_stringify __argz_next])
 
-#   if test "${ac_cv_func_stpcpy+set}" != "set"; then
-#     AC_CHECK_FUNCS(stpcpy)
-#   fi
-#   if test "${ac_cv_func_stpcpy}" = "yes"; then
-#     AC_DEFINE(HAVE_STPCPY)
-#   fi
-
    AM_LC_MESSAGES
    AM_GLIB_WITH_NLS
 
@@ -270,17 +142,6 @@ strdup __argz_count __argz_stringify __a
      fi
    fi
 
-#   dnl The reference to <locale.h> in the installed <libintl.h> file
-#   dnl must be resolved because we cannot expect the users of this
-#   dnl to define HAVE_LOCALE_H.
-#   if test $ac_cv_header_locale_h = yes; then
-#     INCLUDE_LOCALE_H="#include <locale.h>"
-#   else
-#     INCLUDE_LOCALE_H="\
-#/* The system does not provide the header <locale.h>.  Take care yourself.  */"
-#   fi
-#   AC_SUBST(INCLUDE_LOCALE_H)
-
    dnl Determine which catalog format we have (if any is needed)
    dnl For now we know about two different formats:
    dnl   Linux libc-5 and the normal X/Open format
@@ -295,19 +156,6 @@ strdup __argz_count __argz_stringify __a
    dnl po2tbl.sed is always needed.
    sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
      $srcdir/po/po2tbl.sed.in > po/po2tbl.sed
-
-#   dnl In the intl/Makefile.in we have a special dependency which makes
-#   dnl only sense for gettext.  We comment this out for non-gettext
-#   dnl packages.
-#   if test "$PACKAGE" = "gettext"; then
-#     GT_NO="#NO#"
-#     GT_YES=
-#   else
-#     GT_NO=
-#     GT_YES="#YES#"
-#   fi
-#   AC_SUBST(GT_NO)
-#   AC_SUBST(GT_YES)
 
    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
    dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
--- /dev/null	Fri Aug  3 01:21:03 2001
+++ glib/gintl.h	Tue Aug 21 01:13:08 2001
@@ -0,0 +1,54 @@
+/* gintl.h - gettext functions
+ *
+ * Copyright (C) 1999 Tom Tromey
+ * Copyright (C) 2000 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef __G_INTL_H__
+#define __G_INTL_H__
+
+#include <glibconfig.h>
+
+#ifdef GLIB_HAS_LIBINTL_H
+
+#include <libintl.h>
+#define g_textdomain textdomain
+#define g_gettext gettext
+#define g_dgettext dgettext
+#define g_bindtextdomain bindtextdomain
+#define g_bind_textdomain_codeset bind_textdomain_codeset
+#define g_gettext_noop(String) (String)
+
+#else
+
+G_BEGIN_DECLS
+
+char *g_textdomain              (const char *domain_name);
+char *g_gettext                 (const char *msgid);
+char *g_dgettext                (const char *domain_name,
+				 const char *msgid);
+char *g_bindtextdomain          (const char *domain_name,
+				 const char *dir_name);
+char *g_bind_textdomain_codeset (const char *domain_name,
+				 const char *codeset);
+#define g_gettext_noop(String) (String)
+
+G_END_DECLS
+
+#endif /* GLIB_HAS_LIBINTL_H */
+	
+#endif /* __G_INTL_H__ */
--- /dev/null	Fri Aug  3 01:21:03 2001
+++ glib/gintl.c	Wed Aug 22 00:59:48 2001
@@ -0,0 +1,664 @@
+/* gintl.c - i18n functions
+ *
+ *  Copyright 2001 Alexander Larsson <alexl redhat com>.
+ *
+ * GLib is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * GLib 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GLib; see the file COPYING.LIB.  If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ *   Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <string.h>
+#include <errno.h>
+#include <locale.h>
+
+#include "glib.h"
+#include "gintl.h"
+
+#ifndef GLIB_HAS_LIBINTL_H
+
+/* FIXME: fix this on win32 and maybe use LOCALEDIR */
+#define DEFAULT_LOCALE_DIR "/usr/share/locale"
+
+#define SWAB(_val, _do_swab) ((_do_swab)?(GUINT32_SWAP_LE_BE (_val)):(_val))
+
+static char *current_domain = NULL;
+
+static GHashTable *domains = NULL;
+
+typedef struct {
+  guint32 length;
+  guint32 offset;
+} string_data;
+
+typedef struct {
+  char *base;
+
+  gboolean need_swab;
+  int num_strings;
+  string_data *original;
+  string_data *translated;
+  
+  guint32 *hash;
+  guint32 hash_len;
+
+  gchar *codeset;
+} GettextCatalog;
+
+typedef struct {
+  char *name;
+  char *directory;
+  GettextCatalog *cat;
+  gchar *out_codeset;
+  GIConv iconv;
+
+  GHashTable *cache;
+} Domain;
+
+static const char     *get_locale        (void);
+static Domain         *get_domain        (const char     *domain_name,
+					  gboolean        create);
+static GettextCatalog *load_catalog      (Domain         *domain);
+static GettextCatalog *get_catalog       (Domain         *domain);
+static string_data *   lookup_message    (GettextCatalog *cat,
+					  const char     *message);
+static char           *translate_message (Domain         *domain,
+					  const char     *message);
+static void            free_catalog      (GettextCatalog *catalog);
+static void            free_domain       (Domain         *domain);
+
+
+/* The hash function was taken from glibc.
+ *  Copyright (C) 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
+ */
+#define HASHWORDBITS 32
+static inline guint32
+hash_string (const char *str)
+{
+  guint hval, g;
+
+  /* Compute the hash value for the given string.  */
+  hval = 0;
+  while (*str != '\0')
+    {
+      hval <<= 4;
+      hval += (guint32) *str++;
+      g = hval & ((guint32) 0xf << (HASHWORDBITS - 4));
+      if (g != 0)
+	{
+	  hval ^= g >> (HASHWORDBITS - 8);
+	  hval ^= g;
+	}
+    }
+  return hval;
+}
+
+char *
+g_textdomain (const char *domain_name)
+{
+  if (domain_name)
+    {
+      g_free (current_domain);
+      current_domain = g_strdup (domain_name);
+    }
+  else if (!current_domain)
+    current_domain = g_strdup ("messages"); /* Default domain */
+  
+  return current_domain;
+}
+
+char *
+g_gettext (const char *msgid)
+{
+  return g_dgettext (g_textdomain (NULL), msgid);
+}
+
+char *
+g_dgettext (const char *domain_name,
+	    const char *msgid)
+{
+  Domain *domain;
+  char *translation;
+  
+  g_return_val_if_fail (msgid != NULL, NULL);
+  
+  if (domain_name == NULL)
+    return (char *)msgid;
+  
+  domain = get_domain (domain_name, TRUE);
+
+  translation = translate_message (domain, msgid);
+
+  if (translation == NULL)
+    return (char *)msgid;
+
+  
+  
+  return translation;
+}
+
+char *
+g_bindtextdomain (const char *domain_name,
+		  const char *dir_name)
+{
+  Domain *domain;
+  
+  g_assert (domain_name != NULL);
+  
+  domain = get_domain (domain_name, TRUE);
+
+  if (dir_name)
+    {
+      g_free (domain->directory);
+      domain->directory = g_strdup (dir_name);
+    }
+  
+  return domain->directory;
+}
+
+char *
+g_bind_textdomain_codeset (const char *domain_name,
+			   const char *codeset)
+{
+  Domain *domain;
+  
+  g_assert (domain_name != NULL);
+  
+  domain = get_domain (domain_name, TRUE);
+
+  if (codeset)
+    {
+      g_free (domain->out_codeset);
+      domain->out_codeset = g_strdup (codeset);
+
+      if (domain->iconv &&
+	  domain->iconv != (GIConv)-1)
+	g_iconv_close (domain->iconv);
+      domain->iconv = 0;
+    }
+  
+  return domain->out_codeset;
+}
+
+static GettextCatalog *
+get_catalog (Domain *domain)
+{
+  if (domain->cat)
+    return domain->cat;
+
+  domain->cat = load_catalog (domain);
+  
+  return domain->cat;
+}
+
+static const char *
+get_locale (void)
+{
+  const char *locale;
+
+#ifdef G_OS_WIN32      
+  locale = g_win32_getlocale ();
+  if (locale && locale[0] != '\0')
+    return locale;
+#else
+
+#ifdef HAVE_LC_MESSAGES
+  locale = setlocale (LC_MESSAGES, NULL);
+#else
+  locale = setlocale (LC_CTYPE, NULL);
+#endif
+  if (locale && locale[0] != '\0')
+    return locale;
+#endif
+
+  /* Last resort, fall back on the LANG environment variable */
+  locale = g_getenv ("LANG");
+  if (locale && locale[0] != '\0')
+    return locale;
+
+  /* Found nothing. Return the C locale */
+  return "C";
+}
+
+static Domain *
+get_domain (const char *domain_name, gboolean create)
+{
+  Domain *domain;
+  const char *codeset;
+
+  if (domains == NULL)
+    domains = g_hash_table_new_full (g_str_hash,
+				     g_str_equal,
+				     NULL,
+				     (GDestroyNotify)free_domain);
+
+  domain = g_hash_table_lookup (domains, domain_name);
+
+  if (domain)
+    return domain;
+
+  if (create)
+    {
+      domain = g_new0 (Domain, 1);
+      domain->name = g_strdup (domain_name);
+      domain->directory = g_strdup (DEFAULT_LOCALE_DIR);
+      g_get_charset (&codeset);
+      domain->out_codeset = g_strdup (codeset);
+      g_hash_table_insert (domains, domain->name, domain);
+      
+      domain->cache = g_hash_table_new_full (g_str_hash,
+					     g_str_equal,
+					     NULL,
+					     g_free);
+
+      return domain;
+    }
+
+  return NULL;
+}
+
+static GettextCatalog *
+load_mo_file (char *file)
+{
+  char *contents;
+  guint32 *words;
+  guint32 offs;
+  gsize len;
+  GettextCatalog *cat;
+  string_data *str;
+  char *charset;
+  size_t length;
+  
+  if (!g_file_get_contents (file,
+			    &contents,
+			    &len, NULL))
+    return NULL;
+
+  if (len < 28)
+    {
+      /* Can't be a .mo file. To small */
+      g_free (contents);
+      return NULL;
+    }
+  
+  cat = g_new (GettextCatalog, 1);
+  cat->base = contents;
+
+  words = (guint32 *)contents;
+  
+  if (words[0] == 0x950412de)
+    cat->need_swab = FALSE;
+  else if (words[0] == 0xde120495)
+    cat->need_swab = FALSE;
+  else
+    {
+      /* Wrong magic number */
+      g_free (contents);
+      g_free (cat);
+      return NULL;
+    }
+
+  if ( (words[1] != 0) /* Wrong version number */ ||
+       (words[6] == 0) /* No hashtable */)
+    {
+      g_free (contents);
+      g_free (cat);
+      return NULL;
+    }
+
+  cat->num_strings = SWAB (words[2], cat->need_swab);
+  
+  offs = SWAB (words[3], cat->need_swab);
+  cat->original = (string_data *)(contents + offs);
+  
+  offs = SWAB (words[4], cat->need_swab);
+  cat->translated = (string_data *)(contents + offs);
+  
+  cat->hash_len = SWAB (words[5], cat->need_swab);
+
+  offs = SWAB (words[6], cat->need_swab);
+  cat->hash = (guint32 *)(contents + offs);
+
+  str = lookup_message (cat, "");
+
+  charset = cat->base + SWAB (str->offset, cat->need_swab);
+
+  charset = strstr (charset, "charset=");
+  if (charset)
+    {
+      charset += strlen ("charset=");
+      length = strcspn (charset, " \t\n");
+
+      cat->codeset = g_malloc (length + 1);
+      memcpy (cat->codeset, charset, length);
+      cat->codeset[length] = 0;
+    }
+  else
+    {
+      const char *codeset;
+      g_get_charset (&codeset);
+      cat->codeset = g_strdup (codeset);
+    }
+
+  return cat;
+}
+
+static GList *
+generalize_locale (const char *locale)
+{
+  GList *list = NULL;
+  char *str;
+  char *modifier;
+  char *codeset;
+  char *territory;
+  char *language;
+
+  /* LOCALE can consist of up to four recognized parts for the XPG syntax:
+
+		language[_territory[ codeset]][ modifier]
+
+     Beside the first part all of them are allowed to be missing.  If
+     the full specified locale is not found, the less specific one are
+     looked for.  The various parts will be stripped off according to
+     the following order:
+		(1) codeset
+		(2) territory
+		(3) modifier
+  */
+
+  language = g_strdup (locale);
+
+  modifier = strrchr (language, '@');
+  if (modifier)
+    {
+      *modifier++ = 0;
+    }
+  
+  codeset = strrchr (language, '.');
+  if (codeset)
+    {
+      *codeset++ = 0;
+    }
+  
+  territory = strrchr (language, '_');
+  if (territory)
+    {
+      *territory++ = 0;
+    }
+
+  if (codeset)
+    {
+      str = g_strconcat (language,
+			 (territory)?"_":"",
+			 (territory)?territory:"",
+			 ".",
+			 codeset,
+			 (modifier)?"@":"",
+			 (modifier)?modifier:"",
+			 NULL);
+      list = g_list_append (list, str);
+    }
+  
+  if (territory)
+    {
+      str = g_strconcat (language,
+			 "_",
+			 territory,
+			 (modifier)?"@":"",
+			 (modifier)?modifier:"",
+			 NULL);
+      list = g_list_append (list, str);
+    }
+  
+  if (modifier)
+    {
+      str = g_strconcat (language,
+			 "@",
+			 modifier,
+			 NULL);
+      list = g_list_append (list, str);
+    }
+
+  list = g_list_append (list, g_strdup (language));
+
+  g_free (language);
+
+  return list;
+}
+
+
+static GettextCatalog *
+load_catalog (Domain *domain)
+{
+  char *dir;
+  const char *locale;
+  char *file;
+  GettextCatalog *cat;
+  GList *langs, *l;
+
+  dir = domain->directory;
+  locale = get_locale ();
+  langs = generalize_locale (locale);
+  
+  l = langs;
+  while (l)
+    {
+      char *lang = l->data;;
+      
+      file = g_strconcat (domain->directory, "/", lang, "/LC_MESSAGES/", domain->name, ".mo", NULL);
+
+      if (g_file_test (file, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_EXISTS))
+	break;
+      
+      g_free (file);
+      
+      file = NULL;
+
+      l = l->next;
+    }
+
+  if (file == NULL)
+    return NULL;
+
+  cat = load_mo_file (file);
+  
+  g_free (file);
+  
+  return cat;
+}
+
+static void
+free_domain (Domain *domain)
+{
+  g_free (domain->name);
+  g_free (domain->directory);
+  if (domain->cat)
+    free_catalog (domain->cat);
+  g_free (domain->out_codeset);
+  if (domain->iconv)
+    g_iconv_close (domain->iconv);
+  g_hash_table_destroy (domain->cache);
+  g_free (domain);
+}
+     
+static void
+free_catalog (GettextCatalog *catalog)
+{
+  g_free (catalog->base);
+  g_free (catalog);
+}
+
+static string_data *
+lookup_message (GettextCatalog *cat,
+		const char     *message)
+{
+  guint32 hash;
+  guint32 offs;
+  guint32 len;
+  int i;
+  guint32 entry;
+  int entry_len;
+  char *entry_msg;
+  int increment;
+
+  hash = hash_string (message);
+  i = hash % cat->hash_len;
+  len = strlen (message);
+  increment = 1 + (hash % (cat->hash_len - 2));
+    
+  while (1)
+    {
+      entry = SWAB (cat->hash[i], cat->need_swab);
+
+      if (entry == 0)
+	return NULL;
+      
+      entry_len = SWAB (cat->original[entry-1].length, cat->need_swab);
+      if (entry_len >= len) /* Compare with >= because of plural entries with embedded zeros */
+	{
+	  offs = SWAB (cat->original[entry-1].offset, cat->need_swab);
+	  entry_msg = cat->base + offs;
+	  
+	  if (strcmp (message, entry_msg) == 0)
+	    break;
+	}
+
+      i += increment;
+      if (i >= cat->hash_len)
+	i -= cat->hash_len;
+    }
+  
+  return &cat->translated[entry-1];
+}
+
+
+gchar*
+convert (const gchar *str,
+	 gssize       len,
+	 GIConv       cd)
+{
+  gchar *dest;
+  gchar *outp;
+  const gchar *p;
+  gsize inbytes_remaining;
+  gsize outbytes_remaining;
+  gsize err;
+  gsize outbuf_size;
+  gboolean have_error = FALSE;
+  
+  g_return_val_if_fail (str != NULL, NULL);
+
+  if (len < 0)
+    len = strlen (str);
+
+  p = str;
+  inbytes_remaining = len;
+  outbuf_size = len + 1; /* + 1 for nul in case len == 1 */
+  
+  outbytes_remaining = outbuf_size - 1; /* -1 for nul */
+  outp = dest = g_malloc (outbuf_size);
+
+ again:
+  err = g_iconv (cd, (char **)&p, &inbytes_remaining, &outp, &outbytes_remaining);
+  
+  if (err == (size_t) -1)
+    {
+      switch (errno)
+	{
+	case EINVAL:
+	  /* Incomplete text, do not report an error */
+	  break;
+	case E2BIG:
+	  {
+	    size_t used = outp - dest;
+
+	    outbuf_size *= 2;
+	    dest = g_realloc (dest, outbuf_size);
+		
+	    outp = dest + used;
+	    outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
+
+	    goto again;
+	  }
+	case EILSEQ:
+	  have_error = TRUE;
+	  break;
+	default:
+	  have_error = TRUE;
+	  break;
+	}
+    }
+
+  *outp = '\0';
+  
+  if ((p - str) != len) 
+      have_error = TRUE;
+
+  if (have_error)
+    {
+      g_free (dest);
+      return NULL;
+    }
+  else
+    return dest;
+}
+
+
+static char *
+translate_message (Domain     *domain,
+		   const char *message)
+{
+  string_data *str;
+  GettextCatalog *cat;
+  char *in, *out;
+
+  out = g_hash_table_lookup (domain->cache, message);
+  if (out)
+    return out;
+  
+  cat = get_catalog (domain);
+  
+  if (cat == NULL)
+    return NULL;
+  
+  str = lookup_message (cat, message);
+
+  if (str == NULL)
+    return NULL;
+
+  in = cat->base + SWAB (str->offset, cat->need_swab);
+
+  if (domain->iconv == 0)
+    {
+      domain->iconv = g_iconv_open (domain->out_codeset,
+				    cat->codeset);
+      
+      if (domain->iconv == (GIConv)-1)
+	g_warning ("Unable to convert between codesets '%s' and '%s'\n",
+		   cat->codeset, domain->out_codeset);
+    }
+
+  if (domain->iconv != (GIConv)-1)
+    out = convert (in, -1, domain->iconv);
+  else
+    out = in;
+
+  g_hash_table_replace (domain->cache,
+			in, out);
+  
+  return out;
+}
+
+#endif /* GLIB_HAS_LIBINTL_H */

Index: gdk-pixbuf/gdk-pixbuf-i18n.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/gdk-pixbuf-i18n.h,v
retrieving revision 1.1
diff -u -p -r1.1 gdk-pixbuf-i18n.h
--- gdk-pixbuf/gdk-pixbuf-i18n.h	2000/10/06 18:19:18	1.1
+++ gdk-pixbuf/gdk-pixbuf-i18n.h	2001/08/22 05:39:09
@@ -4,14 +4,13 @@
 #include "config.h"
 
 #ifdef ENABLE_NLS
-#include<libintl.h>
-#define _(String) dgettext(GETTEXT_PACKAGE,String)
-#ifdef gettext_noop
-#define N_(String) gettext_noop(String)
-#else
-#define N_(String) (String)
-#endif
+
+#include <glib/gintl.h>
+#define _(String) g_dgettext(GETTEXT_PACKAGE,String)
+#define N_(String) g_gettext_noop(String)
+
 #else /* NLS is disabled */
+
 #define _(String) (String)
 #define N_(String) (String)
 #define textdomain(String) (String)
Index: gtk/gtkintl.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkintl.h,v
retrieving revision 1.2
diff -u -p -r1.2 gtkintl.h
--- gtk/gtkintl.h	2000/07/14 20:08:09	1.2
+++ gtk/gtkintl.h	2001/08/22 05:39:09
@@ -4,14 +4,14 @@
 #include "config.h"
 
 #ifdef ENABLE_NLS
-#include<libintl.h>
-#define _(String) dgettext(GETTEXT_PACKAGE,String)
-#ifdef gettext_noop
-#define N_(String) gettext_noop(String)
-#else
-#define N_(String) (String)
-#endif
+
+#include <glib/gintl.h>
+
+#define _(String) g_dgettext(GETTEXT_PACKAGE,String)
+#define N_(String) g_gettext_noop(String)
+
 #else /* NLS is disabled */
+
 #define _(String) (String)
 #define N_(String) (String)
 #define textdomain(String) (String)
Index: gtk/gtkmain.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmain.c,v
retrieving revision 1.171
diff -u -p -r1.171 gtkmain.c
--- gtk/gtkmain.c	2001/08/15 06:52:19	1.171
+++ gtk/gtkmain.c	2001/08/22 05:39:09
@@ -451,16 +451,16 @@ gtk_init_check (int	 *argc,
 
 #ifdef ENABLE_NLS
 #  ifndef G_OS_WIN32
-  bindtextdomain (GETTEXT_PACKAGE, GTK_LOCALEDIR);
+  g_bindtextdomain (GETTEXT_PACKAGE, GTK_LOCALEDIR);
 #    ifdef HAVE_BIND_TEXTDOMAIN_CODESET
-  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+  g_bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 #    endif
 #  else /* !G_OS_WIN32 */
   {
-    bindtextdomain (GETTEXT_PACKAGE,
-		    g_win32_get_package_installation_subdirectory (GETTEXT_PACKAGE,
-								   g_strdup_printf ("gtk-%d.%d.dll", GTK_MAJOR_VERSION, GTK_MINOR_VERSION),
-								   "locale"));
+    g_bindtextdomain (GETTEXT_PACKAGE,
+		      g_win32_get_package_installation_subdirectory (GETTEXT_PACKAGE,
+								     g_strdup_printf ("gtk-%d.%d.dll", GTK_MAJOR_VERSION, GTK_MINOR_VERSION),
+								     "locale"));
   }
 #endif
 #endif  
Index: gtk/gtkstock.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkstock.c,v
retrieving revision 1.6
diff -u -p -r1.6 gtkstock.c
--- gtk/gtkstock.c	2001/05/25 20:41:43	1.6
+++ gtk/gtkstock.c	2001/08/22 05:39:09
@@ -136,7 +136,7 @@ gtk_stock_lookup (const gchar  *stock_id
     {
       *item = *found;
       if (item->label)
-        item->label = dgettext (item->translation_domain, item->label);
+        item->label = g_dgettext (item->translation_domain, item->label);
     }
 
   return found != NULL;





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]