Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET Core Locale Missing under Linux System #28893

Closed
hajuuk opened this issue Mar 6, 2019 · 2 comments
Closed

.NET Core Locale Missing under Linux System #28893

hajuuk opened this issue Mar 6, 2019 · 2 comments
Labels
area-System.Globalization question Answer questions and provide assistance, not an issue with source code or documentation.
Milestone

Comments

@hajuuk
Copy link

hajuuk commented Mar 6, 2019

When I try to deploy a ASP.NET Core application to a Linux system, I figured out the localization may have some critical issue.

I using following code in .NET Core Console application to isolate the issue, by list all available cultures.

            foreach (var culture in CultureInfo.GetCultures(CultureTypes.AllCultures))
            {
                Console.WriteLine(culture.Name);
            }

Then, the result have lots of differences, not just missing zh-CN or zh-HK.

This file is executed and fetched under Windows 10 1809
Windows.txt

This file is executed and fetched under Linux 4.9.0-8-amd64 dotnet/corefx#1 SMP Debian 4.9.144-3.1 (2019-02-19) x86_64 GNU/Linux
Linux.txt

I can use zh-Hans to replace zh-CN, but it would missing some other things, like DateTime format. Also, most npm package are using zh-CN as default Simp. Chinese language code, so it may also missing the localization data for such npm package, like Bootstrap DatetimePicker, if I directly using Culture infomation for js localization.

Is there have any existing solution for that case? Thanks

@hajuuk
Copy link
Author

hajuuk commented Mar 6, 2019

It might OS dependency, however, I found the debian it self support zh-CN, zh-HK and aa.

Here is the list:

cat /usr/share/i18n/SUPPORTED

Result.txt

@tarekgh
Copy link
Member

tarekgh commented Mar 7, 2019

@hajuuk .NET core is using the underlying OS for globalization. On Linux we use ICU library for the globalization support. When enumerating the locales, we use ICU to do so. ICU has the notion of some aliased locales which are not reported in the enumeration but still can use it (through the alias name). So, such locales will not show in the list returned by CultureInfo.GetCultures but you can still do CultureInfo.GetCultureInfo("zh-CN") and that should still work. We are trying to have a parity with the underlying OS and you can expect some differences between OS's but in general the differences is going smaller and smaller as Windows now using the same source of globalization data.

To summarize, the missing locales in the enumeration doesn't mean you cannot use such locale and the .NET Core behavior is by design globalization behave as the underlying OS as .NET not really carrying any globalization data.

I am closing this issue but feel free to reply back with any question you have and thanks for your report.

@tarekgh tarekgh closed this as completed Mar 7, 2019
@msftgits msftgits transferred this issue from dotnet/corefx Feb 1, 2020
@msftgits msftgits added this to the 3.0 milestone Feb 1, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Globalization question Answer questions and provide assistance, not an issue with source code or documentation.
Projects
None yet
Development

No branches or pull requests

3 participants