Jump to content
  • Advertisement
Sign in to follow this  

Multi-Language supporting app

This topic is 4204 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

What is the best/proper way to write a multi-language supporting app? Creating an 2 dimensional char array and caching all the strings to it? Have a nice day

Share this post

Link to post
Share on other sites
You could use a std::map (I am assuming, you are using C++) that maps strings to strings. Each entry would map a key to the actual string:
e.g. "CONFIRM_QUIT" -> "You you really want to quit?"
Every time you need a string that is presented to the user, you look it up using the corresponding key.
The string you get out of the map would depend on the language you have loaded previously. For example, if you had loaded the German version "CONFIRM_QUIT" would give you the string "Wollen sie das Programm wirklich beenden?"

You could store the strings for each language in a separate file.

Note that there are other things that have to be kept in mind, when you deal with localization. For example date formats and decimal separators vary from language to language.

Share this post

Link to post
Share on other sites
If the game does not require any input from its users, and does not make use of string formatting, then a simple array can work. For most projects, sadly, the only way to deal with that is to use a library like GNU gettext. You can't simply stuff everything in a map and hope it'll work. Format strings, for instance, are problematic. For example:

printf("%s supporting app\n", "multi-languages");

will output something that's valid English, but in French, it'd be

printf("app supportant %s\n", "de multiples langages");.

As you can see, the "%s" is located at the very beginning of the format string in English, and at the very end in French.

As Deaken Frost mentioned, you'll also have issues with:

  • dates and time zones,

  • decimal separators,

  • currencies,

  • measures (imperial vs metrics vs ...),

  • titles (PhD, san, Mr, etc),

  • titles (English capitalizes most first-letters, French doesn't, etc),

  • various cultural meanings attached to symbols and colours in images (I believe white is the colour of funerals in Japan, but not in the West),

  • etc.

That's not even taking into account:

  • encoding (eg Unicode),

  • CJK input (usually requires an "input server", in X lingo),

  • complex scripts input and rendering (Right-to-Left, but can switch to Left-to-Right in the middle of a sentence for various reasons),

  • probably more things I'm not even thinking of right now.

I personally use ICU along with GNU gettext and FriBiDi to solve almost all of these problems(*), at least when coding in C or C++. I'm a GNU/Linux user though: I don't know how easy gettext is to integrate to Visual Studio. If you're using another language (eg Java or a .NET language) or API (eg Qt), it's quite possible the problem's been solved for you.

(*) the only problem it does not solve is CJK input.

EDIT: added FriBiDi.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!