什么可能导致 CurrentCulture 和 CurrentUICulture 默认为明显系统区域性以外的值?
我有一个使用 .NET 3.5 框架的基于 WinForms 的应用程序。该应用程序具有某些资源的本地化版本。
当我在运行 Windows XP 副本的计算机上运行应用程序时,该计算机最初安装时以 en-US 作为默认区域性,但随后将默认区域性设置为 en-CA,CurrentCulture 和 CurrentUICulture 都默认为 en-US 。
为什么会发生这种情况?我需要更改什么才能使应用程序开始使用当前操作系统区域性作为默认区域性?
I have a WinForms based application using the .NET 3.5 framework. The application has localized versions of some resources.
When I run the application on a machine running a copy of Windows XP which was originally installed with en-US as the default culture, but has subsequently had the default culture set to en-CA, both CurrentCulture and CurrentUICulture are defaulting to en-US.
Why might this be happening? What do I need to change so that the application starts using the current OS culture as its default?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用户从未在 Windows 设置中提及她最喜欢的语言本身:她在控制面板中设置了自己的文化,例如英语(加拿大) 又名 en-CA。此选择由 Thread.Culture 属性。 Windows 使用它来确定如何显示和格式化日期(包括日期和月份的格式和名称)、货币等内容。
其他设置是安装 Windows (GUI) 时使用的语言(最有可能 < em>英语(美国)(在您的情况下)。这反映在 Thread.CurrentUICulture。当然,这个选项的可用选择要少得多,因为它反映了 GUI 的语言(菜单、按钮、帮助……)。例如,没有 en-CA CurrentUICulture 这样的东西。
注意:在 Vista+ 和 XP-MUI 中,您可以随后安装其他 GUI 语言并设置每个用户帐户要使用的语言。这反映在 CurrentUICulture 中。
一个常见的误解是认为应该使用文化来确定用户最喜欢的语言。最好依靠 CurrentUICulture。就我而言,Windows 是英语,我的用户偏好(文化)是 fr-BE(法语 - 比利时)。永远不要考虑用法语显示 UI:我安装英语版 Windows 的目的是:我宁愿拥有英语本机 UI,也不愿使用法语翻译版。我的选择背后的原因是有争议的,但这无关紧要。只有我的决定才有意义。
也就是说,我将 5/2/2012 读为 2012 年 2 月 5 日,而不是 5 月 2 日。这就是为什么 fr-BE 是我的语言环境/文化。
FWIW,非 Unicode 程序的语言表示非 Unicode 程序应使用哪个默认代码页(Win32 NLS 术语中的 CP_ACP)。这不会影响您的应用程序,因为 .NET 应用程序是 Unicode。
默认输入语言决定默认键盘布局。这也不是文化背景。
影响文化属性的设置如下:
User never mentions her favorite language per se in Windows settings: She sets her culture in Control Panel, such English (Canada) aka en-CA. This choice is reflected by the Thread.Culture property. It is used by Windows to determine how to display and format things such as dates (including format and names of days and months), currencies,...
The other setting is the language in which Windows (GUI) was installed (Most likely English (United States) in your case). This is reflected by Thread.CurrentUICulture. There are of course way less available choices for this one since it reflects the language of the GUI (menus, buttons, help,...). e.g. no such thing as en-CA CurrentUICulture.
Note: In Vista+ and XP-MUI, you can subsequently install additional GUI languages and set the language to be used for each user account. This is reflected in CurrentUICulture.
A common misconception is to believe that Culture should be used to determine user's favorite language. It is better to rely on CurrentUICulture. In my case, Windows is in English and my user preference (Culture) is fr-BE (French - Belgium). Don't ever think of displaying your UI in French: I installed Windows in English for a purpose: I'd rather have a native UI in English rather than a translated one in French. The reasons behind my choice are arguable but this is irrelevant. Only my decision is relevant.
That said, I read 5/2/2012 as Feb 5th 2012 rather than May 2nd. That's why fr-BE is my locale/Culture.
FWIW, Language for non-Unicode Programs says which default codepage (CP_ACP in Win32 NLS parlance)should be used by non Unicode programs. This doesn't affect your app since .NET apps are Unicode.
Default Input Language determines the default keyboard layout. This is not the Culture setting neither.
The setting that affects the Culture property is this one: