Different objects for different langauges...

Started by Technocrat, Fri 08/06/2012 20:40:13

Previous topic - Next topic

Technocrat

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?

monkey0506

#1
Check out Game.TranslationFilename, does exactly what you're asking about.

Code: ags
// 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
}

Deu2000

Or use GetTranslation. Example:

Code: AGS

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


When you uptade the German translation, traduct "LANGUAGE" to "German"



monkey0506

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?

Technocrat

Ah, superb! Now I can get my "Welsh" and "Latin" translations in there too.

SMF spam blocked by CleanTalk