I use a GUI simil-scumm..
For translate my game (it's in italian) I have used the script: if (Game.TranslationFilename == "English") { }
It works but the text of the GUI is translated only on a Hotspot, while on an object or character is in original language.
Why?
You don't have to translate your game that way.
Look up "Translations" in the manual, or read it online (http://www.adventuregamestudio.co.uk/manual/Translations.htm).
Basically, AGS creates a text file with every line and name from the game, the author (or somebody else) writes the translations in the empty lines in between, then the author creates a translation file from the text file.
The translation is complete. All the file txt is translate.
The script changes also the Gui's button when it started with the file English.tra.
But the game not translate the actions (gui text) on objects and characters and the actions on hotspot.
Ah, sorry, I see.
How does the action text end up in the GUI label?
We need to see the code since it seems to be a script-related problem.
In Global Script:
function game_start()
if (Game.TranslationFilename == "English") {
take.NormalGraphic = 71;
take.MouseOverGraphic = 93;
examine.NormalGraphic = 19;
examine.MouseOverGraphic = 70;
talk.NormalGraphic = 113;
talk.MouseOverGraphic = 115;
use.NormalGraphic = 188;
use.MouseOverGraphic =189;
}
It's ok. When use the english.tra the gui's buttons change!
Then:
function repeatedly_execute() {
// put anything you want to happen every game cycle here
string buffer;
string madetext;
int cur_mode;
// Initialize the status line to display the score
StrCopy (madetext, "");
// Now, add text depending on the mode
cur_mode = GetCursorMode();
if (cur_mode == MODE_WALK)
StrCat(madetext,"Vai verso ");
else if (cur_mode == MODE_LOOK)
StrCat (madetext,"Esamina ");
else if (cur_mode == MODE_USE)
StrCat(madetext,"Usa ");
else if (cur_mode == MODE_TALK)
StrCat(madetext,"Parla con ");
else if (cur_mode == 5)
StrCat(madetext,"Raccogli ");
else if (cur_mode == 4) {
StrCat(madetext,"Usa ");
GetInvName (player.activeinv, buffer);
StrCat(madetext,buffer);
StrCat(madetext," con ");
}
Where the madetext ara all translate in english.txt.
When i click on GuiButton (for example Talk To), the action on GUI (scumm) is "Talk to"..
but when i move the cursor on hotspot, characters or objetc the action became "Parla (italian translate of Talk) english name of hotspot/object/character"
Why?
Becuase you don't have a translation of:
"Talk to Fred"
"Talk to Wilma"
you have to manually translate the two parts with the GetTranslation function
Quote from: SSH on Wed 09/04/2008 08:20:51
Becuase you don't have a translation of:
"Talk to Fred"
"Talk to Wilma"
you have to manually translate the two parts with the GetTranslation function
I read the AGS manual but i not understand how i use this "GetTranslation function" in this case.
Assuming you're using 2.72 or later:
function repeatedly_execute() {
// put anything you want to happen every game cycle here
String madetext;
int cur_mode;
// Now, add text depending on the mode
cur_mode = GetCursorMode();
if (cur_mode == MODE_WALK)
madetext = "Vai verso ";
else if (cur_mode == MODE_LOOK)
madetext = "Esamina ";
else if (cur_mode == MODE_USE)
madetext = "Usa ";
else if (cur_mode == MODE_TALK)
madetext = "Parla con ";
else if (cur_mode == 5)
madetext = "Raccogli ";
else if (cur_mode == 4) {
madetext=GetTranslation("Usa ");
madetext=madetext.Append(GetTranslation(player.ActiveInventory.Name));
madetext=madetext.Append(GetTranslation(" con "));
}
Well.. the script don't work.
This is my original script:
#sectionstart repeatedly_execute // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
// put anything you want to happen every game cycle here
string buffer;
string madetext;
int cur_mode;
// Initialize the status line to display the score
StrCopy (madetext, "");
// Now, add text depending on the mode
cur_mode = GetCursorMode();
if (cur_mode == MODE_WALK)
StrCat(madetext,"Vai verso ");
else if (cur_mode == MODE_LOOK)
StrCat (madetext,"Esamina ");
else if (cur_mode == MODE_USE)
StrCat(madetext,"Usa ");
else if (cur_mode == MODE_TALK)
StrCat(madetext,"Parla con ");
else if (cur_mode == 5)
StrCat(madetext,"Raccogli ");
else if (cur_mode == 4) {
StrCat(madetext,"Usa ");
GetInvName (player.activeinv, buffer);
StrCat(madetext,buffer);
StrCat(madetext," con ");
}
// Find out what's under the cursor, and add it to the status line
GetLocationName(mouse.x,mouse.y,buffer);
StrCat(madetext,buffer);
SetLabelText ( 0, 7, madetext);
}
This is the script (modified with SSH'code):
#sectionstart repeatedly_execute // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
// put anything you want to happen every game cycle here
String buffer;
String madetext;
int cur_mode;
// Now, add text depending on the mode
cur_mode = GetCursorMode();
if (cur_mode == MODE_WALK)
madetext = "Vai verso ";
else if (cur_mode == MODE_LOOK)
madetext = "Esamina ";
else if (cur_mode == MODE_USE)
madetext = "Usa ";
else if (cur_mode == MODE_TALK)
madetext = "Parla con ";
else if (cur_mode == 5)
madetext = "Raccogli ";
else if (cur_mode == 4) {
madetext=GetTranslation("Usa ");
madetext=madetext.Append(GetTranslation(player.ActiveInventory.Name));
madetext=madetext.Append(GetTranslation(" con "));
}
// Find out what's under the cursor, and add it to the status line
GetLocationName(mouse.x,mouse.y,buffer);
StrCat(madetext,buffer);
SetLabelText ( 0, 7, madetext);
}
The error is: "Type mismatch: cannot convert 'String*' to 'string'" (the error is situated on line of "GetLocationName(mouse.x,mouse.y,buffer);"
I've tried to delete "String buffer" but, logically, the error is: "undefined symbol buffer"
Change that to:
buffer = Game.GetLocationName(mouse.x, mouse.y);
The old GetlocationName(x,y,string) method is obsolete now.
Quote from: Gilbot V7000a on Fri 11/04/2008 09:36:36
Change that to:
buffer = Game.GetLocationName(mouse.x, mouse.y);
The old GetlocationName(x,y,string) method is obsolete now.
Ok.. but don't work.
What error message do you get?
You'll need to put this code at the end of the function:
buffer = Game.GetLocationName(mouse.x, mouse.y);
madetext=madetext.Append(buffer);
gui[0].Controls[7].AsLabel.Text=madetext;
Quote from: SSH on Fri 11/04/2008 10:47:07
What error message do you get?
You'll need to put this code at the end of the function:
buffer = Game.GetLocationName(mouse.x, mouse.y);
madetext=madetext.Append(buffer);
gui[0].Controls[7].AsLabel.Text=madetext;
Ok. works!
But as I do insert the translation of other actions (examine, talk, take)?
Sorry... but I have not understood this function.
Translations should be done with the translation file mechanism.
Quote from: SSH on Fri 11/04/2008 11:09:56
Translations should be done with the translation file mechanism.
they are translated in the file, but in the game works alone the action "Use with"..
The other actions are not translated when the cursor is on a hotspot o character.
That is still true with the new code?
Ooops, yes, add this line after all the ifs but before the other code:
madetext=GetTranslation(madetext);
No. But it doesn't work.
Now the actions are translated, but if the game is in original language (Italian), they are translated (English)..
The GetTranslation should do nothing if the game is in default langauge. Are you sure it is set back to Italian? But, you can just put this in, instead, if it still doesn't work:
if (IsTranslationAvailable()) madetext=GetTranslation(madetext);
Ok.
Now i use this code:
#sectionstart repeatedly_execute // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
// put anything you want to happen every game cycle here
String buffer;
String madetext;
int cur_mode;
// Now, add text depending on the mode
cur_mode = GetCursorMode();
if (cur_mode == MODE_WALK) {
madetext = "Vai verso ";
}
else if (cur_mode == MODE_LOOK) {
madetext = "Esamina ";
}
else if (cur_mode == MODE_USE) {
madetext = "Usa ";
}
else if (cur_mode == MODE_TALK){
madetext = "Parla con ";
}
else if (cur_mode == 5){
madetext = "Raccogli ";
}
madetext=GetTranslation(madetext );
if (cur_mode == 4) {
madetext=GetTranslation("Usa ");
madetext=madetext.Append(GetTranslation(player.ActiveInventory.Name));
madetext=madetext.Append(GetTranslation(" con "));
}
// Find out what's under the cursor, and add it to the status line
buffer = Game.GetLocationName(mouse.x, mouse.y);
madetext=madetext.Append(buffer);
gui[0].Controls[7].AsLabel.Text=madetext;
}
The translate works, but when i use an inventory item (when i click on "Use" then on object), the game crash!
The error is on line "madetext=GetTranslation(madetext );", it says "null string referencs".
All other actions works good (for the translate).
Ah, OK, you probably only want to run that code when you're not using the cursor mode Use, so stick an if around it to that effect.
Ok. Now it works! Thanks!
Last thing:
When the actions are translate, they are "attached" with object/hotspot/characters.
Example:
(originale version): Usa monitor con Pc
(enghils version): UsemonitorwithPc
I can't insert (in games tool/script) a space before the object/hotspot/characters or a space after the actions because their translation don't work.
You could do this:
Game.GetTranslation("Take %s")
Then use String.Format to insert the hotspot/o/c name.
Use a with b is a bit more complicated:
- "Use !s with %s"
- insert location name
- replace ! with %
- insert inv item name
ok, ok.. thanks! thanks!