Re: [PATCH] For Real - Fixed pluralization in diff reports
- From
Jeff King <peff@peff.net>
- Date
- Aug 1, 2011, 18:06 UTC
- Message-ID
- <20110801180603.GB10636@sigill.intra.peff.net>
- In-Reply-To
- <4E36B8E4.5080900@gmail.com>
On Mon, Aug 01, 2011 at 07:32:04AM -0700, Jon Forrest wrote:
Show 20 quoted lines
> On 8/1/2011 2:58 AM, Sverre Rabbelier wrote: > >Heya, > > > >On Mon, Aug 1, 2011 at 06:46, Jon Forrest<nobozo@gmail.com> wrote: > >> fprintf(options->file, "%s", line_prefix); > >> fprintf(options->file, > >>- " %d files changed, %d insertions(+), %d deletions(-)\n", > >>- total_files, adds, dels); > >>+ " %d file%s changed, %d insertion%s(+), %d deletion%s(-)\n", > >>+ total_files, total_files == 1 ? "" : "s", adds, adds == 1 ? > >>"" : "s", dels, > >>+ dels == 1 ? "" : "s"); > >> } > > > >Also, this is rather detrimental to the i18n effort methinks? > > If the goal if the i18n effort is also to produce grammatically > correct output in all the supported languages then the > tests that my patch would break would have to be rewritten > anyway.
I think he means that auto-pluralization like this cannot be done in an i18n world, as many languages do not simply add "s". Your patch would have to use ngettext, something like this (totally untested and just copying a similar spot in suggest_reattach, as I have never done any i18n myself):
fprintf(options->file,
Q_(" %d file changed,",
" %d files changed",
total_files),
Q_(" %d insertion(+)",
" %d insertions(+)",
adds),
Q_(" %d deletion(-)",
" %d deletions(-)",
dels),
"\n",
total_files, adds, dels);And that gives translators a chance to specify the entire singular and plural versions separately.
-Peff