How can I localize my game? [Xamarin Studio MonoGame iOS]

I want to support more than one language(English) in my iOS project. For example, if the device preferences are set to French, then my game should draw all of its text in French.

At the moment, I draw the text(in English) like this:

SpriteBatch.DrawString (SpriteFont, String, Vector2, Color)

How can I add translations to my game? How can I do that in MonoGame?

My game runs on iPhone.

you could for example have an array of strings

string[] EnglishText = new string[10];
string[] FrenchText = new string[10]

EnglishText[0] = “See you”
FrenchText[0] = “Au revoir”

When setting the language

//As a field
string[] currentLanguageText;

enum Language { English, French};

//In the function
void ChangeLanguage(Language selectedLanguage)
{
switch(selectedLanguage)
{
case English:
currentLanguage = EnglishText; break;
case French:
currentLanguage = FrenchText; break;
}
}

SpriteBatch.DrawString (SpriteFont, currentLanguage[0], Vector2, Color)

An alternative would be to only load the currently selected language from a textfile and reload from a different textfile if you change languages.

These are just ideas, but maybe they work well for your game.

XNA has a great localization sample: https://msdn.microsoft.com/en-us/library/ff966426.aspx
There is some .NET functionality that can help you out rather than managing things manually like @kosmonautgames said.

Resource Dictionary springs to mind…

I used a class I created that is capable of loading one or multiple CSV files that are UTF8 encoded.
Those contain key value pairs. Those may reference each other, can contain values that are indexed and are replaced upon retrieval and some other goodies.
You can define interceptors that allow you to react on character combinations, like anything between parenthesis, to make the contained characters bold, for example…
If you are interested I could extract the code and put it up on github…
Could take me some days though…

I don’t know how to use .resx files in Xamarin Studio, because it’s completeIy different in Visual Studio. I have added three new files(Strings.resx, Stringsfr.resx, Stringsde.resx) to my project, but I don’t know how to modify the files(how can I add my text?) so that I can support 3 different languages(English, French, German) in my game.

Do you know how to modify the files so that I can use three different languages in my Xamarin Studio MonoGame iOS project?

Strings.resx(complete file):

<?xml version="1.0" encoding="utf-8"?>
<root>
	<resheader name="resmimetype">
		<value>text/microsoft-resx</value>
	</resheader>
	<resheader name="version">
		<value>2.0</value>
	</resheader>
	<resheader name="reader">
		<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
	</resheader>
	<resheader name="writer">
		<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
	</resheader>
</root>

I have tried your approach and it works for me on iOS.

I’ve never worked in XS before, so can’t help on that front.