Boost logo

Boost :

From: Christophe (christophe.avoinne_at_[hidden])
Date: 2002-05-31 04:21:57


----- Original Message -----
From: Glew, Andy <andy.glew_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, May 30, 2002 9:44 PM
Subject: RE: [boost] String formatting library: interest?

> But even easier is the non-positional version:
>
> cout << fmt("%name%'s weight is %weight% %unit%")
> .arg("%weight",weight)
> .arg("%unit",unit)
> .arg("%name%",name)
>
> viz
>
> cout << fmt("Le poids de %nom% est %poids% %unites%")
> .arg("%poids%",weight)
> .arg("%unites%",unit)
> .arg("%nom%",name)
>

I think you mean :

cout << fmt("Le poids de %nom% est de %poids% %unites%")...

or

cout << fmt("Le poids de %nom% fait %poids% %unites%")...

:o)

Well, I suppose it is a good idea for easy translation support :

char const displayweightof[2] =
{
    "%n%'s weight is %w% %u%" /* english - default */
    "Le poids de %n% est de %w% %u%" /* french */
};
...

cout << fmt(displayweightof[current_language])
.arg("%w%",weight)
.arg("%u%",unit)
.arg("%n%",name)

If we use %1%, %2% and %3% instaed, that would work too ?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk