Boost logo

Boost :

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


> > Thus we get a program like
> >
> > char* format=N_("Your name is %s, and your age is %d.");
> > printf(format,name,age);
> >
> > When it comes time for internationalization these strings are parsed
> > out to a file where they are given to the translator. The translator
> > sends back a file which contains a map from string to string.
>
> This won't work. You need positional parameters. The problem is with strings
> such as:
>
> char* format=N_("Today's date is %d-%d-%d.");
>
> This cannot be translated because the order of numbers might be different.
> 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.

> 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.

--Karl


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