Reputation: 1532
I have a localized application and I want to set English as the default language, but using "international" formats:
I want to set this as a global app setting, I can't work with annotations for this (as seen in other posts), and the solution should not be view-specific.
In other words, I am looking for an "en-INTERNATIONAL" CultureInfo.
Upvotes: 2
Views: 11606
Reputation: 1532
Adapted from answer by blackn1ght for WPF (as originally requested)
private void Application_Startup(object sender, StartupEventArgs e)
{
var cultureInfo = CultureInfo.GetCultureInfo("en-GB");
var numberFormat = new NumberFormatInfo();
numberFormat.PercentDecimalSeparator = ",";
numberFormat.PercentGroupSeparator = ".";
numberFormat.CurrencyDecimalSeparator = ",";
numberFormat.CurrencyGroupSeparator = ".";
numberFormat.NumberDecimalSeparator = ",";
numberFormat.NumberGroupSeparator = ".";
culture.NumberFormat = numberFormat;
Dispatcher.Thread.CurrentCulture = cultureInfo;
Dispatcher.Thread.CurrentUICulture = cultureInfo;
}
Date format dd/MM/yyyy is used in the UK, so en-GB should satisfy that requirement.
Upvotes: 0
Reputation: 2601
I'm not 100% about this so someone please feel free to correct me if I'm wrong, but this may work:
Global.asax.cs
protected void Application_BeginRequest()
{
var cultureInfo = CultureInfo.GetCultureInfo("en-GB");
Thread.CurrentThread.CurrentCulture = cultureInfo;
Thread.CurrentThread.CurrentUICulture = cultureInfo;
var numberFormat = new NumberFormatInfo();
numberFormat.PercentDecimalSeparator = ",";
numberFormat.CurrencyDecimalSeparator = ",";
numberFormat.NumberDecimalSeparator = ",";
numberFormat.NumberGroupSeparator = ".";
Thread.CurrentThread.CurrentCulture.NumberFormat = numberFormat;
}
Upvotes: 3