Re: problem with plural-forms - Mailing list pgsql-hackers

From Aidan Van Dyk
Subject Re: problem with plural-forms
Date
Msg-id 20090526143603.GB15213@yugib.highrise.ca
Whole thread Raw
In response to Re: problem with plural-forms  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: problem with plural-forms  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
* Alvaro Herrera <alvherre@commandprompt.com> [090526 10:06]:
> Tom Lane wrote:
>
> > That advice is, if not outright wrong, at least incredibly
> > short-sighted.  The method breaks the instant you have any additional
> > values to print.  For example, this ain't gonna work:
> >
> >        printf (ngettext ("One file removed, containing %lu bytes",
> >                          "%d files removed, containing %lu bytes", n),
> >                n, total_bytes);
>
> I think it should use the %2$s style specifier in that case.  This
> should work:
>
> >        printf (ngettext ("One file removed, containing %2$lu bytes",
> >                          "%d files removed, containing %lu bytes", n),
> >                n, total_bytes);

From the glibc printf man page:  "There  may  be no gaps in the numbers of arguments specified using   '$'; for
example,if arguments 1 and 3 are specified, argument 2 must   also be specified somewhere in the format string." 

So, is skipping 1 allowed?

But, it *is* a commonly used form, especially in translations (where
orders of things need to be flipped), and is already used in many of the
translated PG .po files.

That said, I do think the "msgid" should be using the % args, not words
for a few reasons:
1) Make it more clear for translators the arguments and their ordering  without having to visit the source code
2) On crufty systems without gettext, I wouldn't expect them to support m$  modifiers then either...
3) Greg's "these are numbers, not sentences" is how I expect the system  to work...

a.

--
Aidan Van Dyk                                             Create like a god,
aidan@highrise.ca                                       command like a king,
http://www.highrise.ca/                                   work like a slave.

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: problem with plural-forms
Next
From: Magnus Hagander
Date:
Subject: Re: generic options for explain