updating oE trsprintf


include locale.e 
namespace locale 
public function trsprintf(sequence fmt, sequence data, object langmap = 0) 

returns a formatted string with automatic translation performed on the parameters.

  1. fmt : A sequence. Contains the formatting string. See printf for details.
  2. data : A sequence. Contains the data that goes into the formatted result. see printf for details.
  3. langmap : An object. Either 0 (the default) to use the default language maps, or the result returned from lang_load to specify a particular language map.

A sequence, the formatted result.


This works very much like the sprintf function. The difference is that the fmt sequence and sequences contained in the data parameter are translated before passing them to sprintf. If an item has no translation, it remains unchanged.

Further more, after the translation pass, if the result text begins with "__", the "__" is removed. This function can be used when you do not want an item to be translated.

Example 1:
-- Assuming a language has been loaded and 
--   "greeting" translates as '%s %s, %s' 
--   "hello"  translates as "G'day" 
--   "how are you today" translates as "How's the family?" 
sequence UserName = "Bob" 
sequence result = trsprintf( "greeting", {"hello", "__" & UserName, "how are you today"}) 
   --> "G'day Bob, How's the family?" 
Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu