From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Jan Nieuwenhuizen Newsgroups: gmane.lisp.guile.devel Subject: Re: i18n, gettext support Date: Wed, 01 Sep 2004 18:25:12 +0200 Organization: Jan at Appel Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87zn4ayn13.fsf@peder.flower> References: <200408202226.10769.bruno@clisp.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1094055975 32236 80.91.224.253 (1 Sep 2004 16:26:15 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 1 Sep 2004 16:26:15 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Sep 01 18:25:45 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1C2Xvc-00055L-00 for ; Wed, 01 Sep 2004 18:25:44 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C2Y0Y-0005DA-91 for guile-devel@m.gmane.org; Wed, 01 Sep 2004 12:30:50 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1C2Y0N-0005Cl-P4 for guile-devel@gnu.org; Wed, 01 Sep 2004 12:30:39 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1C2Y0L-0005CS-Sq for guile-devel@gnu.org; Wed, 01 Sep 2004 12:30:39 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C2Y0L-0005CO-Ns for guile-devel@gnu.org; Wed, 01 Sep 2004 12:30:37 -0400 Original-Received: from [194.109.24.29] (helo=smtp-vbr9.xs4all.nl) by monty-python.gnu.org with esmtp (Exim 4.34) id 1C2XvH-0004x5-Cv for guile-devel@gnu.org; Wed, 01 Sep 2004 12:25:23 -0400 Original-Received: from peder.flower (appel.xs4all.nl [80.126.34.178]) by smtp-vbr9.xs4all.nl (8.12.11/8.12.11) with ESMTP id i81GPJSM053948; Wed, 1 Sep 2004 18:25:19 +0200 (CEST) (envelope-from janneke@gnu.org) Original-Received: from localhost ([127.0.0.1] helo=peder.flower ident=janneke) by peder.flower with esmtp (Exim 4.34) id 1C2Xv7-0004xx-AJ; Wed, 01 Sep 2004 18:25:13 +0200 Original-To: Bruno Haible In-Reply-To: <200408202226.10769.bruno@clisp.org> (Bruno Haible's message of "Fri, 20 Aug 2004 22:26:10 +0200") User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) X-Virus-Scanned: by XS4ALL Virus Scanner X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:4062 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:4062 --=-=-= Bruno Haible writes: > I plan to use this sample "hello world" program as an example. Is this OK > with you, the guile developers? Attached is a patch with gettext C bindings for GUILE (which I tried to avoid before). When this gets included in GUILE, we can make the final changes to hello-guile.scm. Greetings, Jan. --=-=-= Content-Disposition: attachment; filename=guile-1.7.1.jcn1.diff ? debug ? doconf ? guile-config/libtool.m4 ? guile-config/ltdl.m4 ? guile-readline/ice-9 ? guile-readline/libtool.m4 ? libguile/i18n.c ? libguile/i18n.h ? libguile/init.loT Index: ChangeLog =================================================================== RCS file: /cvsroot/guile/guile/guile-core/ChangeLog,v retrieving revision 1.444 diff -p -u -r1.444 ChangeLog --- ChangeLog 27 Aug 2004 01:10:20 -0000 1.444 +++ ChangeLog 1 Sep 2004 16:17:14 -0000 @@ -1,3 +1,7 @@ +2004-09-01 Jan Nieuwenhuizen + + * configure.in: Add i18n checks. + 2004-08-27 Kevin Ryde * configure.in (AC_CHECK_MEMBERS): Add struct sockaddr.sin_len and Index: configure.in =================================================================== RCS file: /cvsroot/guile/guile/guile-core/configure.in,v retrieving revision 1.251 diff -p -u -r1.251 configure.in --- configure.in 27 Aug 2004 01:09:48 -0000 1.251 +++ configure.in 1 Sep 2004 16:17:14 -0000 @@ -637,6 +637,14 @@ AC_TRY_LINK([#include ], [mpz_import (0, 0, 0, 0, 0, 0, 0);] , , [AC_MSG_ERROR([At least GNU MP 4.1 is required, see http://swox.com/gmp])]) +dnl i18n tests +AC_CHECK_HEADERS([gettext.h libintl.h]) +AC_CHECK_FUNCS(gettext) +if test $ac_cv_func_gettext = no; then + AC_CHECK_LIB(intl, gettext) +fi +AC_CHECK_FUNCS([bindtextdomain textdomain]) + ### Some systems don't declare some functions. On such systems, we ### need to at least provide our own K&R-style declarations. Index: libguile/ChangeLog =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/ChangeLog,v retrieving revision 1.2137 diff -p -u -r1.2137 ChangeLog --- libguile/ChangeLog 27 Aug 2004 12:46:11 -0000 1.2137 +++ libguile/ChangeLog 1 Sep 2004 16:17:17 -0000 @@ -1,3 +1,8 @@ +2004-09-01 Jan Nieuwenhuizen + + * i18n.h: + * i18n.c: New file. + 2004-08-27 Marius Vollmer * strings.c (SCM_STRINGP): Accept all strings. Index: libguile/Makefile.am =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/Makefile.am,v retrieving revision 1.191 diff -p -u -r1.191 Makefile.am --- libguile/Makefile.am 24 Aug 2004 22:11:35 -0000 1.191 +++ libguile/Makefile.am 1 Sep 2004 16:17:17 -0000 @@ -97,7 +97,7 @@ libguile_la_SOURCES = alist.c arbiters.c gc.c gc-mark.c gc-segment.c gc-malloc.c gc-card.c gc-freelist.c \ gc_os_dep.c gdbint.c gh_data.c gh_eval.c gh_funcs.c gh_init.c \ gh_io.c gh_list.c gh_predicates.c goops.c gsubr.c guardians.c hash.c \ - hashtab.c hooks.c init.c inline.c ioext.c keywords.c \ + hashtab.c hooks.c i18n.c init.c inline.c ioext.c keywords.c \ lang.c list.c \ load.c macros.c mallocs.c modules.c numbers.c objects.c objprop.c \ options.c pairs.c ports.c print.c procprop.c procs.c properties.c \ @@ -113,7 +113,7 @@ DOT_X_FILES = alist.x arbiters.x async.x error.x eval.x evalext.x extensions.x feature.x fluids.x fports.x \ futures.x \ gc.x gc-mark.x gc-segment.x gc-malloc.x gc-card.x goops.x \ - gsubr.x guardians.x hash.x hashtab.x hooks.x init.x ioext.x \ + gsubr.x guardians.x hash.x hashtab.x hooks.x i18n.x init.x ioext.x \ keywords.x lang.x list.x load.x macros.x mallocs.x modules.x \ numbers.x objects.x objprop.x options.x pairs.x ports.x print.x \ procprop.x procs.x properties.x random.x rdelim.x read.x root.x rw.x \ @@ -187,7 +187,7 @@ modinclude_HEADERS = __scm.h alist.h arb error.h eval.h \ evalext.h extensions.h feature.h filesys.h fluids.h fports.h futures.h \ gc.h gdb_interface.h gdbint.h \ - goops.h gsubr.h guardians.h hash.h hashtab.h hooks.h init.h \ + goops.h gsubr.h guardians.h hash.h hashtab.h hooks.h i18n.h init.h \ inline.h ioext.h \ iselect.h keywords.h lang.h list.h load.h macros.h mallocs.h modules.h \ net_db.h numbers.h objects.h objprop.h options.h pairs.h ports.h posix.h \ Index: libguile/init.c =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/init.c,v retrieving revision 1.159 diff -p -u -r1.159 init.c --- libguile/init.c 24 Aug 2004 22:13:07 -0000 1.159 +++ libguile/init.c 1 Sep 2004 16:17:17 -0000 @@ -477,6 +477,7 @@ scm_init_guile_1 (SCM_STACKITEM *base) scm_init_properties (); scm_init_hooks (); /* Requires smob_prehistory */ scm_init_gc (); /* Requires hooks, async */ + scm_init_i18n (); scm_init_ioext (); scm_init_keywords (); scm_init_list (); Index: libguile/numbers.c =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/numbers.c,v retrieving revision 1.260 diff -p -u -r1.260 numbers.c --- libguile/numbers.c 24 Aug 2004 16:43:50 -0000 1.260 +++ libguile/numbers.c 1 Sep 2004 16:17:18 -0000 @@ -5848,8 +5848,8 @@ scm_init_numbers () scm_dblprec[10-2] = (DBL_DIG > 20) ? 20 : DBL_DIG; #endif -#ifdef GUILE_DEBUG - check_sanity (); +#ifdef FIXME__GUILE_DEBUG + check_sanity (); #endif exactly_one_half = scm_permanent_object (scm_divide (SCM_I_MAKINUM (1), --- ../ugh-cvs/libguile/libguile.h 1970-01-01 01:00:00 +0100 +++ libguile/i18n.h 2004-09-01 18:12:57 +0200 @@ -0,0 +1,43 @@ +/* classes: h_files */ + +#ifndef SCM_I18N_H +#define SCM_I18N_H + +/* Copyright (C) 2004 Free Software Foundation, 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.1 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 + */ + + + +#include "libguile/__scm.h" + + + + + + +SCM_API SCM scm_gettext (SCM string); +SCM_API SCM scm_textdomain (SCM domainname); +SCM_API SCM scm_bindtextdomain (SCM domainname, SCM directory); +SCM_API void scm_init_i18n (void); + +#endif /* SCM_I18N_H */ + +/* + Local Variables: + c-file-style: "gnu" + End: +*/ --- ../ugh-cvs/libguile/libguile.c 1970-01-01 01:00:00 +0100 +++ libguile/i18n.c 2004-09-01 17:38:29 +0200 @@ -0,0 +1,116 @@ +/* Copyright (C) 2004 Free Software Foundation, 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.1 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 + */ + + +#if HAVE_CONFIG_H +# include +#endif + +#ifdef HAVE_GETEXT_H +# include +#endif + +#ifdef HAVE_LIBINTL_H +# include +#endif + +#include "libguile/_scm.h" +#include "libguile/discouraged.h" +#include "libguile/feature.h" +#include "libguile/i18n.h" +#include "libguile/strings.h" + + + +#ifdef HAVE_GETTEXT +SCM_DEFINE (scm_gettext, "gettext", 1, 0, 0, + (SCM string), + "Return gettext lookup of @var{string}.") +#define FUNC_NAME s_scm_gettext +{ + SCM_VALIDATE_STRING (1, string); + return scm_makfrom0str (gettext (SCM_STRING_CHARS (string))); +} +#undef FUNC_NAME +#endif /* HAVE_GETTEXT */ + +#ifdef HAVE_TEXTDOMAIN +SCM_DEFINE (scm_textdomain, "textdomain", 0, 1, 0, + (SCM domainname), + "If optional argument @var{domainname} is supplied, " + "set textdomain." + "Return the textdomain.") +#define FUNC_NAME s_scm_textdomain +{ + char *rv; + char *n; + + if (SCM_UNBNDP (domainname)) + n = NULL; + else + { + SCM_VALIDATE_STRING (1, domainname); + n = SCM_STRING_CHARS (domainname); + } + rv = textdomain (n); + if (rv == NULL) + SCM_SYSERROR; + return scm_makfrom0str (rv); +} +#undef FUNC_NAME +#endif /* HAVE_TEXTDOMAIN */ + +#ifdef HAVE_BINDTEXTDOMAIN +SCM_DEFINE (scm_bindtextdomain, "bindtextdomain", 1, 1, 0, + (SCM domainname, SCM directory), + "Set message catalogs for domain @var{domainname} " + "to directory @{directory}." + "Return the bound directory.") +#define FUNC_NAME s_scm_bindtextdomain +{ + char *rv; + char *d; + + SCM_VALIDATE_STRING (1, domainname); + if (SCM_UNBNDP (directory)) + d = NULL; + else + { + SCM_VALIDATE_STRING (2, directory); + d = SCM_STRING_CHARS (directory); + } + rv = bindtextdomain (SCM_STRING_CHARS (domainname), d); + if (rv == NULL) + SCM_SYSERROR; + return scm_makfrom0str (rv); +} +#undef FUNC_NAME +#endif /* HAVE_BINDTEXTDOMAIN */ + +void +scm_init_i18n () +{ + scm_add_feature ("i18n"); +#include "libguile/i18n.x" +} + + +/* + Local Variables: + c-file-style: "gnu" + End: +*/ --=-=-= -- Jan Nieuwenhuizen | GNU LilyPond - The music typesetter http://www.xs4all.nl/~jantien | http://www.lilypond.org --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel --=-=-=--