Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Ali on Thu 12/05/2011 21:55:14

Title: Translation bug? [Solved]
Post by: Ali on Thu 12/05/2011 21:55:14
Hi!

I think I've found a bug with translations. This bit of script doesn't seem to work in Spanish:
if (iPostcard.Name=="Signed Postcard"){
 sayinv ("I've signed it with Bloodbeard's initials.");
}


Presumably because when translated iPostcard.Name is not reading as "Signed Postcard"? I've replaced it with this bit of script and sent it to the Spanish translator/tester:
if (iPostcard.Name=="Signed Postcard"||iPostcard.Name=="Postal Firmada"){
 sayinv ("I've signed it with Bloodbeard's initials.");
}


But I was wondering if this issues was known about, or understood better by anyone?
Title: Re: Translation bug?
Post by: Khris on Thu 12/05/2011 22:02:26
I think in situations like this you have to use GetTranslation() (http://www.adventuregamestudio.co.uk/manual/GetTranslation.htm):

if (iPostcard.Name==GetTranslation("Signed Postcard")){
  sayinv ("I've signed it with Bloodbeard's initials.");
}


I could be completely wrong though; I've read the command's description about 50 times on several occasions and I'm still not sure when/how to use it exactly.
Title: Re: Translation bug?
Post by: Ali on Thu 12/05/2011 22:30:20
I'll look into it, but it seems like a bit of a design flaw. It would be better if translations could slot in and out neatly without this sort of malarky.

Not a big issue though, thanks for the help!
Title: Re: Translation bug?
Post by: Pumaman on Mon 16/05/2011 00:19:52
Yes, you need to use GetTranslation for that. It's not possible for AGS to determine automatically whether it should translate text in that sort of scenario.
Title: Re: Translation bug?
Post by: Ali on Mon 16/05/2011 00:55:14
Thanks for the reply. I've made the change and it works, though Khris's code gave a 'cannot convert String to string' error. I had to use the slightly more awkward:

if (iCat.Name!=String.Format ("%s", GetTranslation("Fierce Cat Burglar"))){
}


Out of interest, why isn't it safe for AGS to assume that every string ought to be translated before running an operation like this?

EDIT: Thanks for the explanation!
Title: Re: Translation bug?
Post by: monkey0506 on Mon 16/05/2011 02:23:29
It looks like even though the parameter of GetTranslation is a const string (compatible with both the string and String types, and string-literals), the return type is string. The example in the manual uses String.CompareTo, so you could do:

if (iCat.Name.CompareTo(GetTranslation("Fierce Cat Burglar")) == 0)
{
  // ...
}


But I agree that even if this function should be compatible with the string type for backwards compatibility of the type, that perhaps a Game.GetTranslation should be implemented that returns a String..?
Title: Re: Translation bug?
Post by: Pumaman on Mon 23/05/2011 16:19:30
Quote from: Ali on Mon 16/05/2011 00:55:14
Out of interest, why isn't it safe for AGS to assume that every string ought to be translated before running an operation like this?

Not all strings are used for display purposes, and so if AGS tried to translate every string usage in the script, it would end up translating things that shouldn't be translated, and you'd end up with unpredictable results if you were trying to use strings to build up lists or for other things.