I am developing a Xamarin.Forms app (portable class library project) with Visual Studio 2013 CE. First I'm focusing the iOS version.
Now I'm thinking about how to make the app multilingual. I just read the offical Xamarin documentation about it but i realized that this solution only takes the system language of the target device.
In the portable class library I have a Resources folder with three languages: German (default), English and French.
Resource.resx
Resource.en-US.resx
Resource.fr-FR.resx
Resource.Designer.cs
Now i just created a static settings class which looks like this:
public static class Settings
{
public static Dictionary<String, CultureInfo> Languages = new Dictionary<String, CultureInfo> { { "German", new CultureInfo("de-DE") }, { "English", new CultureInfo("en-US") }, { "French", new CultureInfo("fr-FR") } };
public static CultureInfo CurrentCulture = Languages["German"];
public static CultureInfo CurrentUiCulture = Languages["German"];
public static void ChangeCurrentCultureInfo(CultureInfo cultureInfo)
{
Resource.Culture = cultureInfo;
}
}
Now my question is if it's possible to change the culture in the application while runtime with a button click. Maybe something like
Settings.CurrentCulture = Settings.Languages["English"];
Settings.ChangeCurrentCultureInfo(Settings.CurrentCulture);
Does anyone can tell me how this can be done?
Regards