Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>At a small Video Game Company, Black Lantern Studios, I was the Lead developer for a game called Lionel Trains DS. We localized into English, Spanish, French, and German. We knew all the languages up front, so including them at compile time was the only option. (They are burned to a ROM, you see)</p> <p>I can give you information on some of the things we did. Our strings were loaded into an array at startup based on the language selection of the player. Each individual language went into a separate file with all the strings in the same order. String 1 was always the title of the game, string 2 always the first menu option, and so on. We keyed the arrays off of an <code>enum</code>, as <code>integer</code> indexing is very fast, and in games, speed is everything. ( The solution linked in one of the other answers uses <code>string</code> lookups, which I would tend to avoid.) When displaying the strings, we used a <code>printf()</code> type function to replace markers with values. "<em>Train 3 is departing city 1.</em>"</p> <p>Now for some of the pitfalls.</p> <p>1) Between languages, phrase order is completely different. "<em>Train 3 is departing city 1.</em>" translated to German and back ends up being "<em>From City 1, Train 3 is departing</em>". If you are using something like <code>printf()</code> and your string is "<em>Train %d is departing city %d.</em>" the German will end up saying "<em>From City 3, Train 1 is departing.</em>" which is completely wrong. We solved this by forcing the translation to retain the same word order, but we ended up with some pretty broken German. Were I to do it again, I would write a function that takes the string and a zero-based array of the values to put in it. Then I would use markers like <code>%0</code> and <code>%1</code>, basically embedding the array index into the string. <strong><em>Update: @Jonathan Leffler pointed out that a POSIX-compliant <code>printf()</code> supports using <code>%2$s</code> type markers where the <code>2$</code> portion instructs the <code>printf()</code> to fill that marker with the second additional parameter. That would be quite handy, so long as it is fast enough. A custom solution may still be faster, so you'll want to make sure and test both.</em></strong></p> <p>2) Languages vary greatly in length. What was 30 characters in English came out sometimes to as much as 110 characters in German. This meant it often would not fit the screens we were putting it on. This is probably less of a concern for PC/Mac games, but if you are doing any work where the text must fit in a defined box, you will want to consider this. To solve this issue, we stripped as many adjectives from our text as possible for other languages. This shortened the sentence, but preserved the meaning, if loosing a bit of the flavor. I later designed an application that we could use which would contain the font and the box size and allow the translators to make their own modifications to get the text fit into the box. Not sure if they ever implemented it. You might also consider having scrolling areas of text, if you have this problem.</p> <p>3) As far as cross platform goes, we wrote pretty much pure C++ for our Localization system. We wrote custom encoded binary files to load, and a custom program to convert from a CSV of language text into a <code>.h</code> with the enum and file to language map, and a <code>.lang</code> for each language. The most platform specific thing we used was the fonts and the <code>printf()</code> function, but you will have something suitable for wherever you are developing, or could write your own if needed.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload