This extension help translating your game in more languages using by external language files.
This extension does not provide a way to automatically translate your games, but instead helps you replace strings on the fly in-game with their correct translation based on a selected language.
The system works as follows: you create a set of textual translation files, containing a key/value pairs on each line, where the key is used to identify the translation (the value). One translation file per language is needed.
In your game you can load your translations by using translation_load() which will store your translation files in memory in order to grant faster access to the information. Once loaded, a language can be used to display translated text, you do that by first telling the game which language you are currently using (translation_set_locale()), and then by using the t() method on a string. The name of the language is supposed to be the name of the file containing the translation (without extension), therefore if you want to use an italian translation contained in the it.txt file, you must call translation_set_locale('it').
It is also possible to insert automatically variables in a translated text. To do that it is sufficient to insert the string "%i" inside a translation, which will be replaced automatically by the t() method (see below) by passing the variables to be inserted into the string to the function
translation_init(lang) Prepares the translation system. Lang is the default language used for translations. You must call this before any other functions in this gex
translation_load(filename,sep) Loads the translation file by passing a filename, sep is a string which tells the separator used in the translation file between key/translation pairs
translation_unload(lang) Deletes a translation freeing the memory used. Lang is a string containing the language to delete (the name of the tanslation file without extension)
translation_set_locale(lang) Sets the current language used. Lang is a string containing the language to use (the name of the tanslation file without extension)
translation_get_locale() Returns the current locale used for translations
t(string,arg0,arg1,...) This method returns the translated string based on the current locale. If no translation is found, the string itself is returned. The function takes also an arbitrary number of arguments which are used to dynamically insert variables into the translated strings. To do that you have to insert one or more special strings %i into the translation where you want the variable to be, this string will be replaced by your variable during the run time.
For instance, if you have this in your translation file: apples|Today I bought %i apples, you can call show_message(t("apples",4)); to display the message "Today I bought 4 apples"