Now, of course, you'll want to test your different languages. Compile your game. In the same directory, create a text file with the same name as your compiled game, but with ".ini" instead of ".slg".
In this new, empty file add the following line:
LANGUAGE=0Run the game again, and it should behave exactly as it did before the file existed (because 0 is the ID of the default language for your game - the language in which the game was originally written). Now, load up the ".ini" file again and change the 0 for the ID of one of your translations. Save the file and run your game again and you should now see your translation file in action.
In some situations, simply substituting one string for another may not be enough to translate a game into another language. You may have text saved as images, or want to provide alternative ways of building sentences for different languages. Take the following example:
objectType cow ("cow") {So, what would you translate the strings into? Well, I'd have thought something like...
}objectType lookAt ("Look at") {
event default {
say (ego, "What a lovely " + clickedObject + ".");
}
}
cow -> la vacheNow, that's not going to work out quite right, is it? You'd end up with sentences like "C'est une beau la vache" and you'd get all manner of complaints. So, use the getLanguageID function to check which language you're using...
Look at -> Voire
What a lovely -> C'est une beau
. -> .
objectType cow ("cow") {And, of course, add a translation for the new string...
}objectType lookAt ("Look at") {
event default {
if (getLanguageID () == 0) {
say (ego, "What a lovely " + clickedObject + ".");
} else {
say (ego, "SIMPLE LOOK AT PHRASE HERE");
}
}
}
SIMPLE LOOK AT PHRASE HERE -> Ce n'est pas tres interesant.Of course, you can come up with more complicated ways around the problem, but chances are they'll be based on the above theory. Anyway, enough of special cases... time to let your users pick what language they want to use.
sub pickLanguage (number) {
# Create a stack full of lines to output to file
var linesToOutput = newStack ("LANGUAGE=" + number);# Er, output them to a file
saveCustomData (linesToOutput, "Game name.ini");# Launch the game
launch ("Game name.slg");# Close the launcher down
quitGame ();
}
sub pickLanguage (number) {Compile your game and rename it moredata*. Compile your launcher and call it gamedata**. Stick them in the same folder as a copy of the SLUDGE engine, renamed as you see fit. Run the engine and it will automatically find and run gamedata... and when the pickLanguage function is called in gamedata, the launcher will start the game proper and close itself.
# Create a stack full of lines to output to file
var linesToOutput = newStack ("LANGUAGE=" + number);# Er, output them to a file
saveCustomData (linesToOutput, "moredata.ini");# Launch the game
launchWith ("Your renamed SLUDGE engine.exe", "moredata");# Close the launcher down
quitGame ();
}
* = The name moredata can be changed to whatever you want. Just make sure you use the same name as the filename launched by your launcher!
** = You can't change this one. Sorry. If you want the program to run a default SLUDGE compiled game (or launcher), the file must be called gamedata.
Hopefully that's a tiny bit helpful for you all...