Translation bug? [Solved]

Started by Ali, Thu 12/05/2011 21:55:14

Previous topic - Next topic

Ali

Hi!

I think I've found a bug with translations. This bit of script doesn't seem to work in Spanish:
Code: ags
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:
Code: ags
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?

Khris

I think in situations like this you have to use GetTranslation():

Code: ags
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.

Ali

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!

Pumaman

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.

Ali

#4
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:

Code: ags
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!

monkey0506

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:

Code: ags
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..?

Pumaman

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.

SMF spam blocked by CleanTalk