【问题标题】:Installing more cultures on Windows Server 2012在 Windows Server 2012 上安装更多文化
【发布时间】:2015-04-01 14:25:29
【问题描述】:

在 Windows 8.1 机器上,我看到比在 Windows Server 2012 机器上更多的可用文化:791 vs 378。举个具体的例子,服务器机器缺少“en-HK”文化。

这是我用来枚举它们的测试代码:

foreach (var ci in CultureInfo.GetCultures(System.Globalization.CultureTypes.AllCultures).OrderBy(ci => ci.Name))
{
    Console.WriteLine("{0} ({1})", ci.Name, ci.EnglishName);
}

问题:如何在 Windows Server 2012 上安装更完整的文化列表,使其与 Windows 8.1 上可用的内容相匹配?

【问题讨论】:

  • 你能按照这篇文章来创建自定义文化吗?您可能需要枚举 8.1 机器上的所有属性以在 2012 机器上复制它们。这就是我们向某些服务器添加自定义文化的方式。 msdn.microsoft.com/en-us/library/vstudio/…
  • 不确定,当我真的只是想填写官方列表时,为所有人创建自定义文化似乎很复杂。
  • 我明白了,不确定...我们只是需要一种额外的自定义文化。好久不见,你知道了吗?
  • 不,我没有。开始认为没有简单的方法可以做到这一点。 :(
  • @subkamran 您提供的链接已损坏:(

标签: c# globalization cultureinfo windows-server


【解决方案1】:

解决方法是升级运行您系统的机器的操作系统。如此处所述...

https://docs.microsoft.com/en-gb/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c

“版本 8.1”支持 en-HK

8.1 版与“Windows 8.1 和 Windows Server 2012 R2。所有更高版本均受支持。”相关。

所以是的,您会在 Windows 8.1 上看到 en-HK 以在您的服务器上看到它安装 R2 服务包。

【讨论】:

    【解决方案2】:

    这是我用来将自定义文化添加到 2012 的一些 Powershell。这是一个硬编码脚本(抱歉,粗略!)。它以现有文化 ($newCulture) 为基础,在本例中为 en-US。

    这是基于来自 MSDN 的示例 C# 代码,位于“如何:创建自定义文化”下:https://msdn.microsoft.com/en-us/library/ms172469(v=vs.100).aspx

    希望对你有帮助!

    ###################################
    # Add-Culture
    #
    # Edit script to add a new custom culture
    #
    ###################################
    
    function Add-Culture($Servers, $Credential) {    
    
        Invoke-Command {
            # Import System.Globalization
            Add-Type -AssemblyName "sysglobl"
    
            $newCulture = "en-TH"
    
            # Create new CultureAndRegionInfoBuilder
            $cib = New-Object "System.Globalization.CultureAndRegionInfoBuilder" -Args $newCulture, None
    
            # Based on existing en-US culture
            $ci = New-Object "System.Globalization.CultureInfo" -Args "en-US"
            $ri = New-Object "System.Globalization.RegionInfo" -Args "th-TH"
    
            $cib.LoadDataFromCultureInfo($ci)
            $cib.LoadDataFromRegionInfo($ri)
    
            # Set culture values here
            # Naming
            $cib.CultureEnglishName = "English (Thailand)"
            $cib.CultureNativeName = "English (Thailand)"
            $cib.IetfLanguageTag = $newCulture
    
            # RegionInfo
            $cib.RegionEnglishName = "Thailand"
            $cib.RegionNativeName = "Thailand"
    
            # ISO
            $cib.ThreeLetterISOLanguageName = "eng"
            $cib.ThreeLetterWindowsLanguageName = "ENG"
            $cib.TwoLetterISOLanguageName = "en"
            $cib.ThreeLetterISORegionName = "THA"
            $cib.TwoLetterISORegionName = "TH"
            $cib.ThreeLetterISORegionName = "THA"
            $cib.ThreeLetterWindowsRegionName = "THA"
    
            # Currency
            $cib.ISOCurrencySymbol = "THB"
            $cib.CurrencyEnglishName = "Thai Baht"
            $cib.CurrencyNativeName = "Thai Baht"
            $cib.NumberFormat.CurrencySymbol = "฿"
    
            # Dates
            $cib.GregorianDateTimeFormat.ShortDatePattern = "d/M/yyyy";
    
            # Print values
            Write-Verbose ($cib | Format-List | Out-String)
            Write-Verbose ($cib.GregorianDateTimeFormat | Format-List | Out-String)
            Write-Verbose ($cib.NumberFormat | Format-List | Out-String)
    
            $cib.Register();               
    
        } -ComputerName $Servers -Credential $Credential
    
        Write-Output "Registered new culture $newCulture on $servers"
    }
    

    【讨论】:

    • 感谢您的回答!以这种方式解决看起来确实容易得多。无论如何,只有我还是微软应该为这类问题提供一些修复?我的意思是,我遇到了这个问题:stackoverflow.com/questions/44264980/…
    • @GabrielEspinoza 是的,微软提供了“修复”,它位于 Windows Server 2012 的 R2 服务包中
    • 这有点小题大做...不确定完成此操作后安装 R2 服务包的结果如何。除非我非常绝望,否则我会避免使用受支持的文化或安装 Microsoft 的更新或新操作系统是更好的解决方案
    猜你喜欢
    • 2014-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-05
    • 1970-01-01
    • 2018-03-16
    • 2016-08-01
    • 1970-01-01
    相关资源
    最近更新 更多