Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2003:
[Freeciv-Dev] (PR#3376) print exact number of points in science dialog
Home

[Freeciv-Dev] (PR#3376) print exact number of points in science dialog

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ggracian@xxxxxxx
Subject: [Freeciv-Dev] (PR#3376) print exact number of points in science dialog
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 9 Sep 2003 09:04:50 -0700
Reply-to: rt@xxxxxxxxxxxxxx

[jjc@xxxxxxxxxxxxxxxxxx - Mon Sep  8 21:44:28 2003]:

> On Mon, Sep 08, 2003 at 11:54:36AM -0700, Jason Short wrote:
> > jjc@xxxxxxxxxxxxxxxxxx wrote:
> >
> > > This patch adds a display of the number of tech points per turn in
> > > the gtk and gtk2 science dialogs.  Now science dialog says things
> like:
> > > Research speed: 20 turns/advance (14 bulbs/turn)
> > > This saves you from having to add up all the bulbs manually in the
> city
> > > dialog.
> >
> > I'm no expert, but I'm pretty positive PL_ cannot be used in this
> way:
> >
> > >      my_snprintf(text, sizeof(text),
> > > +         PL_("Research speed: %d turn/advance (%d bulbs/turn)",
> > > +             PL_("Research speed: %d turns/advance (%d bulb/turn)",
> > > +                 "Research speed: %d turns/advance (%d bulbs/turn)",
> > > +                 bulbs_per_turn),
> > > +             turns_to_advance),
> > > +         turns_to_advance, bulbs_per_turn);
> >
> > Remember that some languages don't do plurals the way English does:
> > there may be three or more forms corresponding to arbitrary
> different
> > patterns, not just "singular" (for 1) and "plural" (for more than
> 1).
> 
> Well, it works in English for all the possible combinations.

Obviously...

> (turn
> bulb is not
> possible since an advance always requires at least 4 bulbs.) It will
> expand via a macro defined in common/fcintl.h to:
> ngettext(("turn bulbs"),ngettext(("turns bulb"),("turns
> bulbs"),bulbs_per_turn),turns_to_advance)
> which makes sense to me.
> I certainly agree that it will not work with three or more forms for
> languages
> that have such a beast, but I don't see how the original
> PL_("turn","turns",turns_to_advance) would work any better.

I assure you it does :-).  The translations are defined in the
language's po file, and the ngettext call returns the proper one for the
value of turns_to_advance.

Take a look at po/pl.po:

- The Plural-Forms line defines how plurals are chosen:

"Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 &&
(n%100<10 "
"|| n%100>=20) ? 1 : 2;\n"

- Then the translations give the different forms:

msgid "%3d turn"
msgid_plural "%3d turns"
msgstr[0] "%d tura"
msgstr[1] "%d tury"
msgstr[2] "%d tur"

This will not work with recursive PL_ calls.  It will have a better
chance work with multiple calls to snprintf to build the buffer
piece-by-piece.  OTOH that may not work with some languages (if the
phrase has to be moved around depending on plurality).

jason



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