Direct output of CultureInfo on different machines

I rely on the .NET CultureInfo object to get the parent culture of some custom cultures (custom in the sense that they represent countries paired with unofficial languages, for example: "en-IT" or "fr-DE").

Everything works fine, but I ran into a problem when it comes to traditional Chinese (zh-hant) paired with China (usually this should be paired with Hong Kong).

The problem is this: on my development machine (Windows 10), I have a different conclusion than the one I have on the intermediate server (Windows Server 2008R2) for the Parent property for a specific culture.

On this page, each “traditional” culture has a “CHT” (LCID 0x7C04) as its parent culture. https://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.parent(v=vs.110).aspx

This is the console application that I run:

class Program
{
    static void Main(string[] args)
    {
        System.Console.WriteLine(System.Environment.Version.ToString());
        System.Console.WriteLine("zh-Hant-CN");
        System.Console.WriteLine("Parent Name is: " + System.Globalization.CultureInfo.CreateSpecificCulture("zh-Hant-CN").Parent.Name);
        System.Console.WriteLine("Parent LCID is: " + System.Globalization.CultureInfo.CreateSpecificCulture("zh-Hant-CN").Parent.EnglishName);
        System.Console.WriteLine("Parent LCID is: " + System.Globalization.CultureInfo.CreateSpecificCulture("zh-Hant-CN").Parent.LCID);
        System.Console.WriteLine("zh-Hans-CN");
        System.Console.WriteLine("Parent Name is: " + System.Globalization.CultureInfo.CreateSpecificCulture("zh-Hans-CN").Parent.Name);
        System.Console.WriteLine("Parent Name is: " + System.Globalization.CultureInfo.CreateSpecificCulture("zh-Hans-CN").Parent.EnglishName);
        System.Console.WriteLine("Parent LCID is: " + System.Globalization.CultureInfo.CreateSpecificCulture("zh-Hans-CN").Parent.LCID);

        System.Console.WriteLine("Same culture: " + System.Globalization.CultureInfo.CreateSpecificCulture("zh-Hant-CN")
           .Equals(System.Globalization.CultureInfo.CreateSpecificCulture("zh-Hans-CN")).ToString()
        );
        System.Console.ReadKey();
    }
}
  • Runs as a compiled exe when debugging with AnyCpu
  • Orientation of the framework 4.6.2 (tried with 4.5.0, the same results)
  • All the latest Windows updates are installed.

Exit on my computer (Windows 10):

4.0.30319.42000
zh-Hant-CN
Parent Name is: zh-CHT
Parent LCID is: Chinese (Traditional) Legacy
Parent LCID is: 31748
zh-Hans-CN
Parent Name is: zh-CHS
Parent Name is: Chinese (Simplified) Legacy
Parent LCID is: 4
Same culture: False

Conclusion: Win Server 2008R2, Win Server 2012R2, Win 8, Win 7. Is:

4.0.30319.42000
zh-Hant-CN
Parent Name is: zh-CHS
Parent LCID is: Chinese (Simplified) Legacy
Parent LCID is: 4
zh-Hans-CN
Parent Name is: zh-CHS
Parent Name is: Chinese (Simplified) Legacy
Parent LCID is: 4
Same culture: True

Any idea what could be causing, or where are the cultures (.Net / Windows) stored?

Thank.

PS: please excuse my bad english.

UPDATE

.... (http://referencesource.microsoft.com/#mscorlib/system/globalization/culturedata.cs,b7941d5fc1e6626d,references) , GetLocaleInfoEx (https://msdn.microsoft.com/en-us/library/windows/desktop/dd318103(v=vs.85).aspx) Windows API ...

, , Api "zh-Han? - *" ERROR_INVALID_PARAMETER, , , , Windows 10...

, .

# 2

, , "zh-Hans-CN", DateTimeFormat: , (一月) (1 月)

.. " : " Windows < 10:

Console.WriteLine("Same month: " + CultureInfo.CreateSpecificCulture("zh-Hant-TW").DateTimeFormat.AbbreviatedMonthNames[0].Equals(CultureInfo.CreateSpecificCulture("zh-Hans-CN").DateTimeFormat.AbbreviatedMonthNames[0]).ToString());

+4

Source: https://habr.com/ru/post/1656203/


All Articles