Archived

This topic is now archived and is closed to further replies.

dalleboy

iostreams and localization

Recommended Posts

How would you solve the localization problems with different languages using iostreams, when the word order is not the same in all supported languages? iostreams outputs the values in left-to-right order and that is not always what you want.
  
// Without localization:

cout << "The tree is " << ColorEnum::ToString(ColorEnum::Green);
// With (some, always LTR) localization:

cout << Resource::ToString(ID_THETREEIS) << ColorEnum::ToString(ColorEnum::Green);
  
In Win32 you could use the FormatMessage function, but are there any good alternatives?

Share this post


Link to post
Share on other sites
How could I use std::locale to split a string and insert a value at the correct place?

Continuing my previous example, how would I make it to output the string in the following word order: "The tree green is"?

The closest thing I can think of was something like:
cout << MyFormatMessage(THETREEIS_1S, ColorEnum::ToString(ColorEnum::Green));
Where THETREEIS_1S is "The tree is %1s." for english, and "The tree %1s is." for japanese (The actual string would be something else, but the %1s is where the color would be written).

HTTP 500 - Strike 1, strike 2.

Share this post


Link to post
Share on other sites