AstroGlider wrote:As far as the language thing goes, in the file fast_general.php (includes directory) there's a nice function by the name of localetext() which translates the text based on the players language settings (provided the entries are present in the locale.xml.txt files.
yes, all files beginning with 'locale.' and finishing with '.xml.txt' (in the directory 'plugins', and in next release also in directory 'custom') are parsed.
You can see the form of the datas in existing files. The form should be something like :
Code: Select all
<pluginname.name1>name1 text in english</pluginname.name1>
<pluginname.name2>name2 text in english</pluginname.name2>
<pluginname.name1>name1 text in french</pluginname.name1>
<pluginname.name2>name2 text in french</pluginname.name2>
<pluginname.name1>name1 text in german</pluginname.name1>
<pluginname.name2>name2 text in german</pluginname.name2>
Note that it can be all in one file or splitted in multiple files. You can do in game a "/debug $_locale" to see all languages parsed data in log (or "/debug $_locale['en']" to only english entries). If the entry does not exist in the player language, then it will use the default language (so english).
As indicated at the end of locale.en.xml.txt, it uses a sprintf(), si you can also use in texts %d / %s / %f etc. replacements and call localeText($login,$tag,...) with the needed args. In such case add a comment about what arg is used in the call, so the translators will know what is what (the nicer order of args is not always the same in all languages).
You can use localeText($login,$tag,...) , or for all users messages in chat, use multiLocaleText(mixed,mixed,...), which build an array usable in ChatSendToLanguage() like methods.
// get localized string using login language
// set login to null if not related to a player
// tag is the searched tag in the locale file
// other params are sprintf like params
// get localized array for ChatSendToLanguage TM method for all used languages
// all mixed are concatenated, each mixed can be :
// - an array($tag,...) , where tag is the searched tag in the locale file, and
// other params in the array are sprintf like params
// - any other value will just be concatenated
You have localeText() examples in many plugins, and multiLocaleText() example in the welcome plugin.
Note also that you can use /lang xx to test your fast and plugin localization in another language without changing your game config.