"printf" style string method?

  • Thread starter Thread starter Robin Tucker
  • Start date Start date
R

Robin Tucker

Given the need to (possibly) alter the position of various elements in a
string due to localisation, is it possible to build a string using a
"printf" style function, such that the source string can also contain the
position of the elements to follow? Eg. :

printf ( "Your database is marked as version %d, but this client
requires a schema version %d" or later", dbVersion, dbRequiredVersion);

where in another locale, we might rearrange this sentance to something like:

printf ( "Your database is marked %d as the version, but this client
requires a %d schema version or later", dbVersion, dbRequiredVersion);



ie: the grammatical rules for different languages are not neccessarily those
of English. At present, I've got resource strings that are just breaking up
the sentances, which I recombine with things like:


theString = "Your database is marked as version " + dbVersion.ToString +
", but this client requires a schema version " + dbRequiredVersion.ToString



Now, although these fragments can be translated, I don't see how it's
possible to alter the ordering as might be required - .....



Is there a method or algorithm analogous to printf I can use in VB?



Cheers



Robin
 
Robin Tucker said:
Given the need to (possibly) alter the position of various elements
in a string due to localisation, is it possible to build a string
using a "printf" style function, such that the source string can
also contain the position of the elements to follow? Eg. :

printf ( "Your database is marked as version %d, but this client
requires a schema version %d" or later", dbVersion,
dbRequiredVersion);

where in another locale, we might rearrange this sentance to
something like:

printf ( "Your database is marked %d as the version, but this
client requires a %d schema version or later", dbVersion,
dbRequiredVersion);



s = string.format("Your database is marked as version {0}, but this client
requires a schema version {1}" or later", dbVersion, dbRequiredVersion)



Armin
 
Superb thankyou.

Armin Zingler said:
s = string.format("Your database is marked as version {0}, but this client
requires a schema version {1}" or later", dbVersion, dbRequiredVersion)



Armin
 
Back
Top