How can I force Localization Culture to en-US for whole applicaiton in Xamarin
I am working with a Xamarin Forms
App.
Setting the Culture in the App
Class did the trick for me.
using System.Globalization;
using System.Threading;
private void SetCultureToUSEnglish()
{
CultureInfo englishUSCulture = new CultureInfo("en-US");
CultureInfo.DefaultThreadCurrentCulture = englishUSCulture;
}
You can set the default culture with following property:
CultureInfo.DefaultThreadCurrentCulture
But this won't work in Android. So for Android you need to set the culture every time an activity gets resumed. You can add a base activity like:
internal class MyBaseActivity : Activity
{
protected override void OnResume ()
{
base.OnResume ();
// Here you would read it from where ever.
var userSelectedCulture = new CultureInfo ("fr-FR");
Thread.CurrentThread.CurrentCulture = userSelectedCulture;
}
}
Found in the xamarin forum: https://forums.xamarin.com/discussion/9764/how-to-set-a-global-cultureinfo-for-an-app