From owner-svn-src-head@FreeBSD.ORG Fri Mar 13 15:38:48 2009 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AC7FD106566B; Fri, 13 Mar 2009 15:38:48 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from server.mypc.hu (server.mypc.hu [87.229.73.95]) by mx1.freebsd.org (Postfix) with ESMTP id 55BDA8FC17; Fri, 13 Mar 2009 15:38:48 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from localhost (localhost [127.0.0.1]) by server.mypc.hu (Postfix) with ESMTP id 7734B14D87AB; Fri, 13 Mar 2009 16:38:47 +0100 (CET) X-Virus-Scanned: amavisd-new at t-hosting.hu Received: from server.mypc.hu ([127.0.0.1]) by localhost (server.mypc.hu [127.0.0.1]) (amavisd-new, port 10024) with LMTP id UZ2yobFEaJGC; Fri, 13 Mar 2009 16:38:42 +0100 (CET) Received: from [192.168.1.105] (catv-80-98-231-64.catv.broadband.hu [80.98.231.64]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by server.mypc.hu (Postfix) with ESMTPSA id 8FE0814D86CB; Fri, 13 Mar 2009 16:38:42 +0100 (CET) Message-ID: <49BA7E01.50000@FreeBSD.org> Date: Fri, 13 Mar 2009 16:38:41 +0100 From: =?ISO-8859-1?Q?G=E1bor_K=F6vesd=E1n?= User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: "Sean C. Farley" References: <200903131040.n2DAecSO061131@svn.freebsd.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r189765 - in head: . lib/libc lib/libc/nls X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2009 15:38:49 -0000 > Nice! I need to find some time to learn how to use NLS. > > Now, you only need to revive the BSD-licensed libiconv[1]. :) I am > kidding; I do not want to start adding more stuff to your plate. > Thank you for strengthening FreeBSD's i18n support. > > Out of curiosity, how does enabling NLS in libc interact with the > devel/gettext port? Well, it's not a bad idea, actually I'm thinking of generating some more catalogs automatically but the problem is that we don't have iconv in the base system. For example, we could easily make a hu_HU.UTF-8 catalog from hu_HU.ISO8859-2 by just converting the encoding of the catalog file. And the same applies to a bunch of locales... I don't really know gettext so I don't know how they can interact. Afaik, gettext is based on some text replacement, while in POSIX.1 NLS, you arrange strings into sets and you identify them with a number inside the sets. Some people think gettext is easier to use but I suspect that it uses a more complex process of building the application itself to process its catalogs. POSIX.1 NLS only needs some additional lines. Here are some code snippets from BSD grep, which uses a single set with 10 messages: grep.h: ================ #ifdef WITHOUT_NLS #define getstr(n) errstr[n] #else #include extern nl_catd catalog; #define getstr(n) catgets(catalog, 1, n, errstr[n]) #endif extern char *errstr[]; grep.c: ================ #ifndef WITHOUT_NLS #include nl_catd catalog; #endif /* * Default messags to use when NLS is disabled or no catalogue * is found. */ char *errstr[] = { "", /* 1*/ "(standard input)", /* 2*/ "cannot read bzip2 compressed file", /* 3*/ "unknown --color option", /* 4*/ "usage: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A num] [-B num] [-C[num]]\n", /* 5*/ "\t[-e pattern] [-f file] [--binary-files=value] [--color=when]\n", /* 6*/ "\t[--context[=num]] [--directories=action] [--label] [--line-buffered]\n", /* 7*/ "\t[--null] [pattern] [file ...]\n", /* 8*/ "unknown --binary-files option", /* 9*/ "Binary file %s matches\n" /*10*/ "%s (BSD grep) %s\n", }; And then you can simply use getstr(n), where n is the number of the string you want to use. It will work with catalogs and with NLS disables, as well. -- Gabor Kovesdan FreeBSD Volunteer EMAIL: gabor@FreeBSD.org .:|:. gabor@kovesdan.org WEB: http://people.FreeBSD.org/~gabor .:|:. http://kovesdan.org