Localization using TGB 1.7.5
by Giuseppe De Francesco · in Torque Game Builder · 04/23/2011 (11:55 am) · 8 replies
Hey guys,
I'm porting a title on TGB and I got stuck on how to localize it. I've spent hours between forum and docs without finding any useful info.
I see that there is a sim LangTable and... that's all! I really don't have time to reverse engineer the engine to understand how to use it :(
any hint?
Thanks,
Pino
I'm porting a title on TGB and I got stuck on how to localize it. I've spent hours between forum and docs without finding any useful info.
I see that there is a sim LangTable and... that's all! I really don't have time to reverse engineer the engine to understand how to use it :(
any hint?
Thanks,
Pino
About the author
In the software eng. field since 1981, in charge of R&D during last 10 years. IEEE Senior Member (and volunteer).
#2
08/05/2011 (5:08 am)
So I guess the untold answer here is: write your own localization system :(
#3
LangFile:
---------
Handle several string serialized in a file for one language.
We have to create one file by language.
Loading a file insert each string in a vector of string, i think that the index of the vector is used later for loading a translated string by its index.
LangTable:
----------
Handle several Language Files and allow to select them at run time.
This class provides several scripts methods for set a language or add a language.
After we have to use the "langTableMod" and "textID" fields in the gui editor and give the simobject name of the LangTable object already created.
But... there is not editor for create the language file loaded by the language table...
And i don't think that this is available for other things than GuiControl.
Sorry Giuseppe.
08/05/2011 (8:30 am)
I saw 2 class:LangFile:
---------
Handle several string serialized in a file for one language.
We have to create one file by language.
Loading a file insert each string in a vector of string, i think that the index of the vector is used later for loading a translated string by its index.
LangTable:
----------
Handle several Language Files and allow to select them at run time.
This class provides several scripts methods for set a language or add a language.
After we have to use the "langTableMod" and "textID" fields in the gui editor and give the simobject name of the LangTable object already created.
But... there is not editor for create the language file loaded by the language table...
And i don't think that this is available for other things than GuiControl.
Sorry Giuseppe.
#4
08/05/2011 (8:54 am)
I did find those as well, but there is no docs about the file format and how to generate it (the named app is missing)... I really don't have time to mind-compile the related engine's classes :(
#5
I'm using XML-based string 'table' for my game. Not sure if XML is intended to be used this way, but it does work flawlessly so far. Here is minimalistic example of language file and a bit of my Strings class:
08/05/2011 (9:07 am)
I didn't even know there is such thing. Anyway, LangTable doesn't looks like it can be used right out of the box. It does some _really_ weird things in there...I'm using XML-based string 'table' for my game. Not sure if XML is intended to be used this way, but it does work flawlessly so far. Here is minimalistic example of language file and a bit of my Strings class:
<Strings>
<language name="English (US)" id="default" />
<language name="OtherLang" id="othrlng" />
<stringName default="String value" othrlng="Localized string value" />
</Strings>function cStrings::GetString(%this, %stringName) {
if(%this.xml.pushFirstChildElement(%stringName)) {
%str = %this.xml.attribute(%this._useLanguage);
// if no value for specified language grab default value
if(%str $= "") %str = %this.xml.attribute("default");
%this.xml.popElement();
}
else echo("String named " @ %stringName @ " not found in Strings");
return %str;
}
#7
08/05/2011 (12:23 pm)
I can confirm the localization code for Torque has not been well maintained. I know it's broken in Torque 3D, so I could probably assume the same for TGB 1.7.5. I'm not sure what it would take to get it working, but the lang tables were the localization pipe for Torque.
#8
08/05/2011 (3:49 pm)
@Mich: that's too bad... I really needed that for that project (it's on a different engine now). I'll see if that TGE solution can be adapted for future use, but I've so little time that I guess I'll not really doing it :(
Associate Giuseppe De Francesco
DFT Games Ltd