Problems with langc.exe
by Cesar · in Torque Game Engine · 07/10/2008 (4:02 am) · 5 replies
Hi!, im trying to add multilanguage support in my game.
At "onStart()":
$I18N::langTable = new LangTable();
exec("my.game/client/language/english.cs");
$I18N::langTable.addLanguage("my.game/client/language/English.lso", "English");
%numLang = $I18N::langTable.getNumLang();
$I18N::langTable.setDefaultLanguage(0);
$I18N::langTable.setCurrentLanguage(0);
$I18N::languageCode = $I18N::langTable.getCurrentLanguage();
%langName = $I18N::langTable.getLangName($I18N::languageCode);
"numLang=1" and "langName=English", good. With:
echo($I18N::langTable.getString($STR_DISC_08));
Output window say:
"lease insert the XXXX Game Disc.E"
Bad...In "English.lang" (UTF-8 without BOM):
STR_DISC_08=This is a data-only Game Disc.\nPlease insert the XXXX Game Disc.
I generated "english.lso" with "langc -ls English.lang English".
Any clue? Thanks in advance!!
At "onStart()":
$I18N::langTable = new LangTable();
exec("my.game/client/language/english.cs");
$I18N::langTable.addLanguage("my.game/client/language/English.lso", "English");
%numLang = $I18N::langTable.getNumLang();
$I18N::langTable.setDefaultLanguage(0);
$I18N::langTable.setCurrentLanguage(0);
$I18N::languageCode = $I18N::langTable.getCurrentLanguage();
%langName = $I18N::langTable.getLangName($I18N::languageCode);
"numLang=1" and "langName=English", good. With:
echo($I18N::langTable.getString($STR_DISC_08));
Output window say:
"lease insert the XXXX Game Disc
Bad...In "English.lang" (UTF-8 without BOM):
STR_DISC_08=This is a data-only Game Disc.\nPlease insert the XXXX Game Disc
I generated "english.lso" with "langc -ls English.lang English".
Any clue? Thanks in advance!!
About the author
#2
void Stream::readString(char buf[256])
{
U8 len;
read(&len);
read(S32(len), buf);
buf[len] = 0;
}
to:
void Stream::readString(char buf[256])
{
U32 len;
read(&len);
read(U32(len), buf);
buf[len] = 0;
}
07/11/2008 (2:08 am)
NStream.cc (line 54)void Stream::readString(char buf[256])
{
U8 len;
read(&len);
read(S32(len), buf);
buf[len] = 0;
}
to:
void Stream::readString(char buf[256])
{
U32 len;
read(&len);
read(U32(len), buf);
buf[len] = 0;
}
#3
07/11/2008 (2:58 am)
Good find. Thanks for the fix. Goes straight to the repo.
#4
Now, I use custom Stream::readString(char buf[256]) in lang.cc
Maybe langc.exe would write length string with U8?
07/11/2008 (4:14 am)
Wait!, GFont::read(Stream& io_rStream) [gFont.cc] use Stream::readString(char buf[256]) and want 1 byte to read lenght.Now, I use custom Stream::readString(char buf[256]) in lang.cc
Maybe langc.exe would write length string with U8?
#5
Re-reading the original code, it turns out that it is correct. Somehow I was thinking the value was read in as an S8 when in fact it is not.
So yes, the original code is correct.
Unfortunately, that doesn't help you with your problem. Hope to be able to squeeze in some half hour or so sometime soon to look into this.
07/11/2008 (4:25 am)
Should not be checking in fixes in-between shopping tours....Re-reading the original code, it turns out that it is correct. Somehow I was thinking the value was read in as an S8 when in fact it is not.
So yes, the original code is correct.
Unfortunately, that doesn't help you with your problem. Hope to be able to squeeze in some half hour or so sometime soon to look into this.
Torque 3D Owner Cesar
1 byte, string lenght (only 256 chars?)
2 byte, string data
...
strings
...
But langc.exe always (UTF8 with BOM, without BOM or ANSI file) insert three empty bytes (00) between lenght and the data. Why?
Has anyone used langc.exe?
GarageGames make langc.exe? Is source code available?
Thanks.