C#CultureInfo.CurrentCulture说en_US,但是我的Windows设置设为南非 [英] C# CultureInfo.CurrentCulture says en_US but my Windows settings are set to South Africa

查看:759
本文介绍了C#CultureInfo.CurrentCulture说en_US,但是我的Windows设置设为南非的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 8.1控制面板中将地区/位置更改为南非。当我从Visual Studio 2013启动我的应用程序并获取CultureInfo.CurrentUICulture时,它仍然显示 en-US。

I changed my Region/Location in my Windows 8.1 control panel to be South Africa. When I start up my app from Visual Studio 2013 and get the CultureInfo.CurrentUICulture it still says "en-US".

public CultureInfo getCurrentCulture() {
    if (CultureInfo.DefaultThreadCurrentUICulture != null) {
        return CultureInfo.DefaulThreadCurrentUICulture;
    } else {
        return CultureInfo.CurrentUICulture;
    }
}

我也尝试过CultureInfo.CurrentCulture而不是CurrentUICulture ,但它们的行为方式相同。如何通过代码确定用户的实际语言环境?还是我通过Windows设置错误地设置了区域?

I've also tried CultureInfo.CurrentCulture instead of CurrentUICulture, but they are behaving the same way. How do I determine what the user's real locale is via code? Or am I setting the region incorrectly via the Windows settings?

我的应用格式化了货币字符串等,因此我需要确保它使用了正确的货币符号。南非对我来说是一个很好的用例,因为它们仍然使用英语,但是区域号码的格式不同。

My app formats currency strings and such and I need to make sure it is using the correct currency symbols. South Africa is a good use case for me because they still use the English language, but just have different regional number formatting.

推荐答案

我想我应该把它作为答案。

I guess I should make this an answer.

Windows区分用户的实际位置,所需的本地化(格式)属性和运行语言。例如,说西班牙语的用户可能位于英国,但希望使用美国英语格式。 CultureInfo.CurrentCulture 是指格式 标签,位于区域控制面板中更改非unicode程序的语言。 (以上链接之一中显示的用户界面对于Win8而言已有些过时;请参见此处用于Win8类似物。)

Windows distinguishes between the physical location of the user, the desired localization (formatting) properties, and the running language. For instance, a Spanish-speaking user could be located in the UK but want American English formatting. CultureInfo.CurrentCulture refers to the settings under the "Formats" tab of the Regions control panel. (The user interfaces shown in one of the links above are a little out-of-date for Win8; see here for the Win8 analogs.)

本文提供了有关各种区域性属性以及如何在用户界面中进行设置: YACVCP(还有另一个CurrentCulture与CurrentUICulture帖子)

This article has a little more information about the various culture properties and how they are set in the user interface: YACVCP (Yet another CurrentCulture vs. CurrentUICulture post)

因此,要测试南非的货币字符串这样,您必须将格式下拉菜单更改为英语(南非)并重新运行。

So, to test South African currency strings and such, you have to change the "Format" drop-down to "English (South Africa)" and rerun.

此外,通过实验,我发现Visual当我重新运行应用程序时,Studio 2008(我使用的是什么)并不总是能在语言环境中进行更改。这可能是托管过程的某种错误。重新启动和重新运行我的应用程序通常似乎可以解决问题。关闭并重新打开Visual Studio总是如此。

Also, by experimentation, I have found that Visual Studio 2008 (what I am using) doesn't always pick up the change in locale when I rerun my application. This may be some sort of bug with the Hosting Process. Restarting and rerunning my application usually seems to cure the problem. Closing and re-opening Visual Studio always does.

(注意-我正在使用Win7。)

(Note -- I'm using Win7.)

这篇关于C#CultureInfo.CurrentCulture说en_US,但是我的Windows设置设为南非的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆