- Home /
How do I make a mobile game in all languages and able to switch text in different languages in the game and sell on google play and Apple Store
Right now I have my game in English . I want the game in the all languages and sell the game on Google Play and the Apple Store . How do I code that ? Can I make possible for the play to switch the text in different language in the game if the programmer gives the player an option to do that in the main menu ?
Answer by Pindwin · Aug 29, 2016 at 07:14 AM
Well, while knowing
all the languages
may prove difficult, there is a certain method for allowing your scripts to use translation: using TranslationTags.
Basically, all your strings need to be statically defined in a certain script (using statics is generally a bad practice, but this is the case you may do it freely - you are not going to change them, just define them in your code). You have, e.g.
public class TranslationTags
{
public static string NewGame = "NewGame";
}
Now, you need your translations to be stored in a file - XML or Json will do. Json is more readable, while XML has better support of .Net without using external libraries, so I personally prefer to use XML. It's generally useful to have separate XML file for each translation - so you have en-US for English, fr-FR for French etc. In each XML, you store a key-value pairs, where key is your game tag, and value - actual translation. You may also store some other data in your XML, i.e. encoding of the specific language you are willing to use. Your XML may look like:
<xml language="pl-PL"><key>NewGame</key><value>Nowa gra</value></xml>
Then in game, choosing a language equals to switching to specific XML file. When chosen, you construct:
using System.Collections.Generic;
class TranslationsFromXML : MonoBehaviour
{
void Awake()
{
ReadValuesFromYourXMLAndSaveToDictionary(string defaultLanguage)
{
... your particular implementation ...
}
}
public static Dictionary<string, string> Translations = new Dictionary<string, string>();
}
Populate it with data from your XML, so every time you want to display a string, instead you display the value associated with that string.
myGuiElement.text = TranslationsFromXML.Translation[TranlationTags.NewGame]
I'm sure you can figure the rest out :)
Answer by SebaTK · Aug 29, 2016 at 04:54 AM
Well I don't know how you can get it on the app stores and such, but i can give tips of how you can change languages.
Make a script : 'SettingsScript' or whatever... And make a settings button. When this button is pressed a boolean : 'isPaused' or something like that needs to be set to true. When this happens all other scripts need to know about this and go into an loop that only stops when the bool is false. Only you're 'SettingsScript' doesn't need it. Then you have the other settings buttons and a language button. When pressed it needs to show the possible languages (I would recommend that the default language is Englisch). Then it only needs to:
GameObject.Find("Some Text #1 in Dutch").GetComponent.UI.Text;
//This is brobably wrong i typed it out of the top of my head :P
You need to do this for all text in the game and voila there you have it! The further details you'll be able to find on you're own it's not that hard!
Hope this helped! XD
Your answer
Follow this Question
Related Questions
My assets size is 12MB but the game size is 66MB on iphone.. why? 3 Answers
Android : How to manage game display with on-screen front cameras ? 1 Answer
Avoid auto device capitalization for textfields on mobile 1 Answer
Use LightSensor using new InputSystem 0 Answers
Admob ads not showing on iOS devices 0 Answers