After writing a couple of Android applications I thought it would be nice if one could implement support for multiple languages in their Unity projects as easily as in an Android project. I had this idea a few months ago and finally got around to writing it.
With Unity Multiple Language Support you can easily include multi-lingual support in your Unity projects through XML. Simply create one or more XML files with the strings that have multiple translations and then reference those strings in your scripts with a common identifier. XML format is as follows:
<?xml version="1.0" encoding="utf-8"?>
<languages>
<English>
<string name="app_name">Some Game</string>
<string name="score_text">Score: </string>
</English>
<French>
<string name="app_name">Certains Jeux</string>
<string name="score_text">Score: </string>
</French>
<German>
<string name="app_name">Einige Spiele</string>
<string name="score_text">Ergebnis: </string>
</German>
</languages>
Once the Lang Class has been initialized to a particular language you can reference the strings stored in your XML file as follows:
var scoreText : String = langClass.getString("score_text") + newScore.ToString();
Furthermore you can reset the language on the fly with the following line:
langClass.setLanguage(Path.Combine(Application.dataPath, "lang.xml"), "French");
The text stored in your XML resource is read as a string so any rich text formatting will remain intact, but youâll need to read up on how to format the XML file for special characters. For the most part characters such as quotes and carats need an escape character.
The main difference between this implementation and Androidâs is that Android requires each language to have itâs own separate XML file while UMLS leaves it up to the developer to decide whether to throw it all into one XML file or split it up into multiple files. For smaller games a single XML file should do just fine, but since all strings from the selected language are stored in RAM larger games might find it useful to use multiple XML resources such as LVL_01.xml, LVL_02.xml, etcetera. RPGs could even split their resources per conversation such as Adam_01.xml and Jenny_07.xml.
Feel free to grab Unity Multiple Language Support off of my Google Drive for free:
https://docs.google.com/file/d/0B6BscJ4Cq-K7WjhTM1B1N1FWSDA/edit?usp=sharing
P.S. Google Drive opens the zip file so you can download individual items. To download the whole zip file just select File â Download.
P.P.S. UMLS provides support for XML resources stored on the local system and resources stored over the web, however; I have not tested UMLS with web based resources so feel free to contact me if youâre having trouble.