Boost logo

Boost :

From: Karl Nelson (kenelson_at_[hidden])
Date: 2001-12-19 14:56:35


> > > You may argue that dates need separate treatment as well, but:
> >
> > Actually it does work...
> >
> > "Today's date is %d-%d-%d" becomes "Today's date is %3$d-%1$d-%2$d"
> >
> > when the translator requires a new order. This is the system used
> > be many i18n projects.
>
> Aha, I get it. Could you point me to some online resource that covers that?

I know GNOME uses this heavily. The function commonly used is gettext.
See
  http://www.iro.umontreal.ca/contrib/po/HTML/gettext.html#Marking

Their example...
printf (gettext ("String `%s' has %d characters\n"), s, strlen (s));
 becomes
   "%2$d Zeichen lang ist die Zeichenkette `%1$s'"

> > > char* format=N_("Error code %d in transaction %d.");
> > >
> > > Maybe in some language a more natural sentence has the transaction
> number
> > > first and the error code second.
> >
> > Exactly. Which is why printf has positional directives.
>
> Which printf? I don't know of the standard C printf supporting positional
> directives.

Unix 98 printf (which should someday make it to implementations.)

http://www.opengroup.org/onlinepubs/7908799/xsh/fprintf.html

This is the main reason that boost really needs a format class (C++ in
general needs it.) I18n and streams are a bad mix.

--Karl


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