Archived

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

iostreams and localization

This topic is 5524 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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?

std::locale?

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 on other sites
No really, how should it be implemented?

• Forum Statistics

• Total Topics
628696
• Total Posts
2984267

• 19
• 9
• 13
• 13
• 11