本文介绍了英国非美国文化的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用Set-Culture(Powershell作为管理员)将当前区域性"设置为"en-DE",这是英语(德国).但是,当我运行不同的PS命令以查看当前区域性"时,我仍然会得到en-US.我也检查了我的地区(格式)和位置.

I am able to use Set-Culture (Powershell as Admin) to set the Current Culture to "en-DE" which is English (Germany). However, when I run the different PS commands to view the Current Culture, I am still getting en-US. I checked my Region (Format) and Location as well.

我还必须将系统区域设置更改为德国(德国)吗?

Do I have to change the system locale as well to Germany (German) ?

这在应用程序中引起错误,因为datetime格式从en-DE到en-US是不同的,并且导致日期被错误地读取.

This is causing an error in an application, because the datetime format is different from en-DE to en-US and causing the date to be read incorrectly.

当我Set-Culturede-DE时,所有内容似乎都处于工作状态.

When I Set-Culture to de-DE, everything appears to be in working order.

我确保以管理员身份运行Powershell控制台,Set-Culture,关闭控制台.打开Powershell并运行Get-Culture[CultureInfo]::CurrentCulture[CultureInfo]::CurrentUICulture以及更多其他内容,以检查并仍然得到en-US

I make sure to run Powershell Console as Administrator, Set-Culture, close console. Open Powershell and run Get-Culture, [CultureInfo]::CurrentCulture, [CultureInfo]::CurrentUICulture and a few more to check and and still getting en-US

推荐答案

注意:使用en-DE 作为区域性标识符-即,混合语言 en (英语)具有通常不相关的地区/国家 DE(德国)-需要 Windows 10发行版为1607或更高版本的 Windows Server 2016 strong>,根据Microsoft .

Note: Use of en-DE as a culture identifier - i.e., mixing language en (English) with normally unrelated region/country DE (Germany) - requires Windows 10 with release channel 1607 or later or Windows Server 2016, according to Microsoft.

但是,在Windows 10 Pro(64位;版本1709,操作系统内部版本:16299.371)上发现,存在一个错误,该错误阻止了这种混合文化的使用.

However, there's a bug that prevents use of such mixed cultures, observed on Windows 10 Pro (64-bit; Version 1709, OS Build: 16299.371)

虽然您可以使用Set-Culture成功设置这种混合文化的值,但随后的会话无法识别它并退回到en-US (如$PSCultureGet-Culture[cultureinfo]::currentCulture)

While you can successfully set such mixed-culture values with Set-Culture, subsequent sessions do not recognize it and fall back to en-US (as reflected in $PSCulture, Get-Culture and [cultureinfo]::currentCulture)

  • This problem has been reported on UserVoice.
  • Note that PowerShell Core is not affected (but it doesn't support Set-Culture).

此答案的其余部分讨论了与漏洞无关的一般设置当前用户的文化.

The rest of this answer discusses persistently setting the current user's culture in general, irrespective of the bug.

Set-Culture -通过注册表-设置未来 PowerShell会话的区域性(仅),而不是当前会话.

Set-Culture - via the registry - sets the culture for future PowerShell sessions (only), not (also) for the current session.

Get-Culture 仅在会话启动时报告当前会话的文化 .也就是说,如果您在会话期间 更改文化(请参见下文),则会在Get-Culture中反映出 not .

Get-Culture, by contrast, only ever reports the current session's culture at session-startup time. That is, if you change the culture during a session (see below), it will not be reflected in Get-Culture.

为了也将新设置的区域性应用于当前会话,除了 Set-Culture调用,还运行以下:

In order to also apply the newly set culture to the current session, run the following in addition to the Set-Culture call:

[cultureinfo]::CurrentCulture = 'de-DE'

重新交互 (命令行)使用:

Caveat re interactive (command-line) use:

  • Windows PowerShell (仍从v5.1版开始)中,在提交每个命令后,将对活动区域性进行 reset 重置.例如,
    [cultureinfo]::CurrentCulture = 'de-DE'; Get-Date可以正常工作,因为它是同一命令行的一部分,但是当仅执行Get-Date作为 next 命令时,当前区域性已恢复为中的当前区域性. >会话启动时间.
    • 此问题已在PowerShell Core 中得到解决.
    • In Windows PowerShell (still as of v5.1), the active culture is reset after every command submitted; e.g.,
      [cultureinfo]::CurrentCulture = 'de-DE'; Get-Date works as expected, because it is part of the same command line, but when executing just Get-Date as the next command, the current culture has reverted to the one that was current at session-startup time.
      • This problem has been fixed in PowerShell Core.

      这种可能令人惊讶的不对称性-Set-Culture仅适用于未来会话,但是Get-Culture报告了当前会话的(启动)文化-在以后的PowerShell Core 版本中可能会更改

      This perhaps surprising asymmetry - Set-Culture only applying to future sessions, but Get-Culture reporting the current session's (startup) culture - is something that may change in future PowerShell Core versions.

      这篇关于英国非美国文化的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 06:26