.NET中的“国际”英语文化是什么?

时间:2014-08-26 10:22:02

标签: c# .net wpf localization cultureinfo

我有一个本地化的应用程序,我想将英语设置为默认语言,但使用" international"格式:

  • 日期格式(日/月/日 - 2014年12月31日)
  • 逗号","作为小数分隔符(0,5 = 1/2)
  • dot"。"千位分隔符(1.000.000 =一百万)

我想将此设置为全局应用设置,我无法使用此注释(如其他帖子中所示),并且解决方案不应该是特定于视图的。

换句话说,我正在寻找一个" en-INTERNATIONAL"的CultureInfo。

2 个答案:

答案 0 :(得分:1)

我不是100%关于这个,所以如果我错了,请随时纠正我,但这可能有用:

<强>的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;
    }

答案 1 :(得分:0)

改编自blackn1ght对WPF的回答(原始要求)

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;
}

日期格式dd / MM / yyyy在英国使用,因此en-GB应满足该要求。