Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Technocrat on Fri 08/06/2012 20:40:13

Title: Different objects for different langauges...
Post by: Technocrat on Fri 08/06/2012 20:40:13
Right now, I'm using English and a German translation with my game. I can tell the game to check TranslationAvailable, and currently use it to make it so that, if the translation is being used, background objects appear in German rather than English.

Since I'm considering adding other languages, is there any way to make the game know which foreign language objects to use, rather than it just being a different language to default?
Title: Re: Different objects for different langauges...
Post by: monkey0506 on Fri 08/06/2012 20:50:56
Check out Game.TranslationFilename, does exactly what you're asking about.

Code (ags) Select
// room script
Object *oDoor; // language-neutral door pointer

Object* GetTranslatedObject(Object *englishObject)
{
  if ((Game.TranslationFilename == "") || (Game.TranslationFilename == "English")) return englishObject;
  if (Game.TranslationFileName == "German")
  {
    if (englishObject == oEnglishDoor) return oGermanDoor;
    // etc.
  }
  else if (Game.TranslationFilename == "French")
  {
    if (englishObject == oEnglishDoor) return oFrenchDoor;
    // etc.
  }
}

function room_Load()
{
  oDoor = GetTranslatedObject(oEnglishDoor); // the oDoor pointer now relates to the appropriate door object, regardless of translation
  // this means you can reference 'oDoor' instead of constantly having to check the translation and find the appropriate object
}
Title: Re: Different objects for different langauges...
Post by: Deu2000 on Fri 08/06/2012 21:20:16
Or use GetTranslation. Example:

Code (AGS) Select

function game_start() {
    // ...
    if(GetTranslation("LANGUAGE")=="German")) {
        // translate stuff
    }
    // other case, keep originals
}


When you uptade the German translation, traduct "LANGUAGE" to "German"
Title: Re: Different objects for different langauges...
Post by: monkey0506 on Fri 08/06/2012 21:49:45
While that would work, why would you add an additional string to the game that you have to make sure is translated, when the engine already has it built-in and automatically updated?
Title: Re: Different objects for different langauges...
Post by: Technocrat on Sat 09/06/2012 19:54:23
Ah, superb! Now I can get my "Welsh" and "Latin" translations in there too.