Jump to content
  • Advertisement


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


iostreams and localization

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

If you intended to correct an error in the post then please contact us.

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!