From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14068 invoked by alias); 17 Feb 2010 20:07:01 -0000 Received: (qmail 14057 invoked by uid 22791); 17 Feb 2010 20:07:00 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from gv-out-0910.google.com (HELO gv-out-0910.google.com) (216.239.58.187) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 17 Feb 2010 20:06:55 +0000 Received: by gv-out-0910.google.com with SMTP id o2so130249gve.10 for ; Wed, 17 Feb 2010 12:06:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.204.0.84 with SMTP id 20mr5597048bka.5.1266437211965; Wed, 17 Feb 2010 12:06:51 -0800 (PST) In-Reply-To: <4B7C3571.60808@gnu.org> References: <206fcf961002170906l1bdca005h3833890d35d7db5c@mail.gmail.com> <4B7C3571.60808@gnu.org> Date: Wed, 17 Feb 2010 20:07:00 -0000 Message-ID: Subject: Re: gcc/cp/pt.c: use ngettext() when needed From: Marco Poletti To: Paolo Bonzini Cc: gdr@integrable-solutions.net, Gabriel Dos Reis , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2010-02/txt/msg00692.txt.bz2 2010/2/17 Paolo Bonzini : > On 02/17/2010 06:06 PM, Gabriel Dos Reis wrote: >> >> On Wed, Feb 17, 2010 at 9:23 AM, Marco Poletti >> wrote: >>> >>> In the file pt.c, there were translatable strings like "redeclared >>> with %d template parameter(s)" that are hard to translate. Instead, >>> it should use the ngettext() function to allow more flexible >>> translations. I've added two functions inform_translated() and >>> error_translated() to diagnostic.c, that are called by pt.c. This >>> is my second patch to GCC, I could have done something wrong. >>> Critics are very appreciated. >> >> I'm uncomfortable with adding these two functions. It is possible to >> just call a preprocessor ngettext() first and give the result to >> error() or inform()? > > Marco, why don't you instead add warning_n/inform_n/error_n, like > > =A0 error_n (TREE_VEC_LENGTH (parms), > =A0 =A0 =A0 =A0 =A0 =A0"redeclared with %d template parameter", > =A0 =A0 =A0 =A0 =A0 =A0"redeclared with %d template parameters", > =A0 =A0 =A0 =A0 =A0 =A0TREE_VEC_LENGTH (parms)); > > (compared to ngettext I'm moving the number argument before the strings, = to > make sure it's not confused with the first positional parameter of printf= ). By "adding" you mean implementing as functions, no macros involved, right? This would be ok IMHO. How do you imagine the prototype? Something like error_n(int,const char*,const char*, ...) or error_n(int,const char*,const char*, int) ? (I prefer the first one, more general) > =A0This can be taught to exgettext with something like this: > > Index: exgettext > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- exgettext =A0 (revision 156795) > +++ exgettext =A0 (working copy) > @@ -112,6 +112,8 @@ function keyword_option(line) { > =A0 =A0 else if (args ~ /c$/) > =A0 =A0 =A0 =A0format=3D"c-format" > > + =A0 =A0if (name ~ /_n$/) n =3D n "," (n + 1) > + > =A0 =A0 if (n =3D=3D 1) { keyword =3D "--keyword=3D" name } > =A0 =A0 else { keyword =3D "--keyword=3D" name ":" n } > =A0 =A0 if (format) { > > Paolo > If you say so :-) I don't understand this code. Marco