Game Development Community

How to localize a game?

by amaranthia · in Torque Game Builder · 11/03/2006 (10:55 pm) · 2 replies

Hi there, I'm trying to figure out a good way to localize a game. I thought about using an array of global variables or a datablock, but both don't seem like a good idea. I thought it would be nice to have an external file with the text strings that can be updated after the game is compiled, but I'm not quite sure how to go about it... Any ideas?

#1
11/04/2006 (1:47 am)
The *best* way to do I don't really know yet. For our game we used the built in support using .lso files and textIDs on gui controls. It works, but it's not ideal, and how it'll turn out once we actually make a full localized version (ie: if there's actually enough demand for it) has yet to be seen.

The system is simple in most cases. You create an external file for each language (eg: english.lang), run the langc tool when you make changes to it (I think langc is still only available in TGE, but it doesn't do that much so it could be replicated easily enough). This tool makes a .cs and .lso file for the language.

On game startup, you'll need to create a LangTable, exec your language files, add each of your .lso files to the LangTable, and then activate your default and current language. Code for this can be found in the this resource: tdn.garagegames.com/wiki/TorqueLocalization.

In your guis, any control that wants to use its textID field needs to have a langTableMod field specified. I'd highly recommend not doing this on every control, but having all your controls on the gui defined as children of a top level parent GuiControl and just defining it in there so all the child controls inherit it. It's too easy to forget otherwise.

If you need to just read a string out of the current language resource file, you can use the L() function, passing it the id defined in those generated .cs files.

Main thing to watch out for is making sure you've got your langTableMod fields set correctly, making it a standard practice to rerun the langc tool after modifying your .lang file, and one of our problems was that our source control picked up .lso as text when it should have been binary and that bit us for a while since changes didn't work right until we caught that. Finally make sure the text editor used to edit the .lang files actually writes out the three byte encoding specifier at the beginning of the file or it won't work. Notepad doesn't do it even when you tell it to save the file as UTF8 (I suggest TextPad).

Now that we've gotten used to the processes it's pretty painless, but it was a bit messy setting it up at first. Good luck.
#2
11/04/2006 (11:01 am)
Thanks Richard, that article has helped!