dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.26k stars 4.73k forks source link

Blazor WASM CultureInfo names returns locale #84016

Closed Cedervall closed 1 year ago

Cedervall commented 1 year ago

Is there an existing issue for this?

Describe the bug

When using CultureInfo.NativeName, CultureInfo.DisplayName or CultureInfo.EnglishName I always get a two letter combination as output. Ex sv (SE), en (US), pt (BR).

Actual output for the code below: Native: sv (SE) Name: sv-SE Display: sv (SE) English: sv (SE)

Expected Behavior

The correct beheavior for would be for sv-SE is to give the output:

Native: svenska (Sverige) Name: sv-SE Display: Swedish (Sweden) English: Swedish (Sweden)

or for pt-BR

Native: português (Brasil) Name: pt-BR Display: Portuguese (Brazil) English: Portuguese (Brazil)

Steps To Reproduce

New Blazor WASM project. In the Index.razor add:

@code {
    protected override void OnInitialized()
    {
        var test = new System.Globalization.CultureInfo("sv-SE");

        Console.WriteLine("Native: " + test.NativeName);
        Console.WriteLine("Name: " + test.Name);
        Console.WriteLine("Display: " + test.DisplayName);
        Console.WriteLine("English: " + test.EnglishName);
    }
}

Needs to be a WASM project. Works as it should in server app, console app etc.

Get the same issue when running dotnet 6

Exceptions (if any)

No response

.NET Version

7.0.100

Anything else?

Get the same result in both Chrome and Edge, has language set to English (US) for the browsers.

ghost commented 1 year ago

Tagging subscribers to this area: @dotnet/area-system-globalization See info in area-owners.md if you want to be subscribed.

Issue Details
### Is there an existing issue for this? - [X] I have searched the existing issues ### Describe the bug When using CultureInfo.NativeName, CultureInfo.DisplayName or CultureInfo.EnglishName I always get a two letter combination as output. Ex sv (SE), en (US), pt (BR). Actual output for the code below: Native: sv (SE) Name: sv-SE Display: sv (SE) English: sv (SE) ### Expected Behavior The correct beheavior for would be for sv-SE is to give the output: Native: svenska (Sverige) Name: sv-SE Display: Swedish (Sweden) English: Swedish (Sweden) or for pt-BR Native: português (Brasil) Name: pt-BR Display: Portuguese (Brazil) English: Portuguese (Brazil) ### Steps To Reproduce New Blazor WASM project. In the Index.razor add: ``` @code { protected override void OnInitialized() { var test = new System.Globalization.CultureInfo("sv-SE"); Console.WriteLine("Native: " + test.NativeName); Console.WriteLine("Name: " + test.Name); Console.WriteLine("Display: " + test.DisplayName); Console.WriteLine("English: " + test.EnglishName); } } ``` Needs to be a WASM project. Works as it should in server app, console app etc. Get the same issue when running dotnet 6 ### Exceptions (if any) _No response_ ### .NET Version 7.0.100 ### Anything else? Get the same result in both Chrome and Edge, has language set to English (US) for the browsers.
Author: Cedervall
Assignees: -
Labels: `area-System.Globalization`
Milestone: -
ghost commented 1 year ago

Tagging subscribers to 'arch-wasm': @lewing See info in area-owners.md if you want to be subscribed.

Issue Details
### Is there an existing issue for this? - [X] I have searched the existing issues ### Describe the bug When using CultureInfo.NativeName, CultureInfo.DisplayName or CultureInfo.EnglishName I always get a two letter combination as output. Ex sv (SE), en (US), pt (BR). Actual output for the code below: Native: sv (SE) Name: sv-SE Display: sv (SE) English: sv (SE) ### Expected Behavior The correct beheavior for would be for sv-SE is to give the output: Native: svenska (Sverige) Name: sv-SE Display: Swedish (Sweden) English: Swedish (Sweden) or for pt-BR Native: português (Brasil) Name: pt-BR Display: Portuguese (Brazil) English: Portuguese (Brazil) ### Steps To Reproduce New Blazor WASM project. In the Index.razor add: ``` @code { protected override void OnInitialized() { var test = new System.Globalization.CultureInfo("sv-SE"); Console.WriteLine("Native: " + test.NativeName); Console.WriteLine("Name: " + test.Name); Console.WriteLine("Display: " + test.DisplayName); Console.WriteLine("English: " + test.EnglishName); } } ``` Needs to be a WASM project. Works as it should in server app, console app etc. Get the same issue when running dotnet 6 ### Exceptions (if any) _No response_ ### .NET Version 7.0.100 ### Anything else? Get the same result in both Chrome and Edge, has language set to English (US) for the browsers.
Author: Cedervall
Assignees: -
Labels: `arch-wasm`, `area-System.Globalization`, `untriaged`
Milestone: -
pavelsavara commented 1 year ago

cc @ilonatommy

ilonatommy commented 1 year ago

Thank you for the report, this is intentional to save space. I am closing as a duplicate of https://github.com/dotnet/runtime/issues/44739.