4

On a Windows 8.1 machine, I'm seeing many more available cultures than on a Windows Server 2012 machine: 791 vs 378. To give a specific example, the server machine is missing the 'en-HK' culture.

Here is the test code I'm using to enumerate them:

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

Question: how can I install the more complete culture list on Windows Server 2012 so that it matches what's available on Windows 8.1?

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • Can you follow this article to create a custom culture? You might need to enumerate all the properties on the 8.1 machine to duplicate them on the 2012 machine. This is how we added custom cultures to some servers. https://msdn.microsoft.com/en-us/library/vstudio/ms172469(v=vs.100).aspx – kamranicus Aug 06 '15 at 18:22
  • Not sure, it seems complicated to create custom cultures for all of those when I'm really just trying to fill in the official list. – David Ebbo Aug 06 '15 at 21:55
  • I see, not sure about that... we just needed an additional custom culture. It's been some time, did you figure this out? – kamranicus Aug 12 '15 at 19:14
  • No I didn't. Starting to think that there is no easy way to do this. :( – David Ebbo Aug 13 '15 at 01:03
  • @subkamran the link you provided is broken :( – Gabriel Espinoza May 30 '17 at 14:16
  • @GabrielEspinoza try this link: https://msdn.microsoft.com/en-us/library/ms172469(v=vs.100).aspx I googled "create custom culture c# msdn" ;D – kamranicus May 30 '17 at 21:34
  • @GabrielEspinoza I added an answer. I use a script to add new cultures, tested on 2012 R2 at least. – kamranicus May 30 '17 at 21:40

2 Answers2

1

The fix is to upgrade the OS of the machine running your system. As documented here...

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

en-HK is supported in "Release 8.1"

Release 8.1 correlates to "Windows 8.1 and Windows Server 2012 R2. Supported in all later versions."

So yes you will see en-HK on Windows 8.1 to see it on your server install the R2 service pack.

Mick
  • 6,527
  • 4
  • 52
  • 67
0

Here's some Powershell I've used to add custom cultures to 2012. This is a hard-coded script (sorry, rough!). It bases a new culture ($newCulture) on an existing one, in this case en-US.

This is based on sample C# code from MSDN, under "How To: Create Custom Cultures": https://msdn.microsoft.com/en-us/library/ms172469(v=vs.100).aspx

Hope it helps!

###################################
# 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"
}
kamranicus
  • 4,207
  • 2
  • 39
  • 57
  • Thank you for your answer! It does look much easier to solve this way. Anyway, is it just me or Microsoft should provide some fix for this kind of issues? I mean, I'm having this problem: https://stackoverflow.com/questions/44264980/windows-server-2012-has-incorrect-decimal-digits-for-currency-on-es-cl-culture/44266249#44266249 – Gabriel Espinoza May 30 '17 at 22:39
  • 1
    @GabrielEspinoza yes Microsoft have supplied "a fix" it's in the R2 service pack for Windows Server 2012 – Mick Oct 18 '19 at 01:02
  • This is a bit of a hack... not sure what the outcome is when you install the R2 service pack after having done this. I would avoid unless I was seriously desperate, either use a supported culture or install an update or new OS from Microsoft is a far better solutution – Mick Oct 18 '19 at 01:06