bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: printing plural values outside unsigned long int range


From: Bruno Haible
Subject: Re: printing plural values outside unsigned long int range
Date: Wed, 23 Aug 2006 19:41:02 +0200
User-agent: KMail/1.9.1

Egmont Koblinger wrote:
> > + @smallexample
> > + printf (ngettext ("One file removed", "%d files removed", n), n);
> > + @end smallexample
> 
> Please don't do so, please don't mention this in the manual!...
> 
> - "One file", "2 files", "3 files" is really inconsistent and really ugly.

Users view something as inconsistent when they see the different outputs
simultaneously. If the message is printed only once by the program, I
don't why they should view this as inconsistent.

When a program ends saying

   Compilation done.

versus

   An error has been encountered. Compilation failed.

versus

   72 errors have been encountered. Compilation failed.

and the user sees only one of these three messages, he won't think it's
inconsistent.

> If "One" is written as text, then it should continue as "Two files", "Three
> files" so it's time to implement a localized number-to-text converter :-)
> Or if numbers are used then "1" should be a number, too.

Feel free to contribute such a number-to-text converter; it might be
useful for GNU gettext users. gettextize already has this (for English
only):

  case "$count" in
    1) count="paragraph";;
    2) count="two paragraphs";;
    3) count="three paragraphs";;
    4) count="four paragraphs";;
    5) count="five paragraphs";;
    *) count="$count paragraphs";;
  esac
  echo "Press Return to acknowledge the previous $count."

> - This approach might easily break scripts that parse the output of the
> command, e.g. cut the number and use it for arithmetic processing.

Yes it can. Likewise the sentence can be restructured so that the number
occurs in the middle of the sentence instead of at the beginning. It's
the responsibility of the script author to cope with it.

In the gettext manual, I'm only listing what is possible: "the number -
always 1 - can be replaced with "one" ". I would have liked to mention
that it is good style or recommended, but it's not the purpose of the
gettext manual to say what is good style and what is not.

> Here I requested the coreutils team and Paul agreed to change this to
> printf (ngettext ("%d file removed", "%d files removed", n), n);

Yes, it's fully under the responsibility of the programmer to decide
whether "1" or "one" is better.

> Now I just wonder why kbabel allows both "nplurals=1" and "msgstr[1]" which
> clearly does not make any sense.

Please encourage the kbabel maintainers to add a sanity check for this.
Note that "msgfmt -c" already signals an error for this usage for some
time. But this is IMO an unrelated issue.

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]