473,503 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"printf" style string method?


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
Nov 21 '05 #1
2 11184
"Robin Tucker" <id*************************@reallyidont.com> schrieb

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

Nov 21 '05 #2
Superb thankyou.

"Armin Zingler" <az*******@freenet.de> wrote in message
news:uq**************@tk2msftngp13.phx.gbl...
"Robin Tucker" <id*************************@reallyidont.com> schrieb

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

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

188
17193
by: infobahn | last post by:
printf("%p\n", (void *)0); /* UB, or not? Please explain your answer. */
8
13631
by: baumann | last post by:
hi all, i hope printf("%#04x\n", 0); will output 0x00, but visual c++ studio 6 outputs 0000. how can i get 0x00? thanks
9
2781
by: geek | last post by:
Hi all, Why does a printf("%d") statement prints this as output and when I do printf("%c") it doesn't print anything. -13361016 Any help would be appreciated. Thanks,
2
2296
by: Jude | last post by:
here is the source code: #include<stdio.h> int main() { float f; scanf("%d%f",&f); printf("The float is %10.5f\n",f); return 0; } when I input 12345.11111,the output is 12345.11133.
19
5432
by: v4vijayakumar | last post by:
why the following statement dumps the core(Segmentation fault)? printf("%s\n", __FILE__);
10
2336
by: lovecreatesbeauty | last post by:
Is parameter type conversion required for the 2nd argument on printf("%p", (void *)&i); ? But one would never call memcpy like: memcpy((void *)pi, (void *)pj, sizeof *pj); /*memcpy((void *)pi,...
51
4050
by: Spidey | last post by:
for(;0;) printf("hello"); even the condition s wrong i get a hello printed on the screen y s this happening
16
2756
by: Gernot Frisch | last post by:
Hi, class MyString { char* m_data; public: MyString(const char* c) { m_data = new char; strcpy(m_data, c);
3
33926
by: Ioannis Vranos | last post by:
Is printf("%ls") for printing wchar_t strings defined in C90, or it was added in C95?
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.