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?
Check out Game.TranslationFilename, does exactly what you're asking about.
// 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
}
Or use GetTranslation. Example:
function game_start() {
// ...
if(GetTranslation("LANGUAGE")=="German")) {
// translate stuff
}
// other case, keep originals
}
When you uptade the German translation, traduct "LANGUAGE" to "German"
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?
Ah, superb! Now I can get my "Welsh" and "Latin" translations in there too.