syntax across languages

11 Feb 2002 17:32:19 +0100

Patrick M Doane <> writes:


> I find sprintf to be not powerful enough for internationalization.  The
> specification of actual values is order dependant which may change from
> language to language. 

not true with advanced printf's:

   There is one last vital consideration for output. The order of words in a
   sentence is different in various languages, for example, ``yellow flower''
   becomes ``la flor amarilla'' en Espanbsp;nol. The differences between
   English and German are equally dramatic. To solve this problem, the
   standard printf() allows the order of the arguments to be handled in
   variable order in the format string. For example, if we have printf(fmt,
   month, date, who); we can use an fmt of %s %d is %s's birthday in English
   to produce ``April 26 is James's birthday'' and %3$s's geburtstag ist %2$d.
   %1$s in German to generate ``James's geburtstag ist 26. April.'' Notice
   that qualifiers like 2$ allows us to reorder the parameters to account for
   differing word order in different languages.