dotnet / runtime

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

Blazor webassembly on DotNet 5 rc2 missing globalization for Bosnian month names #43398

Closed adopilot closed 2 years ago

adopilot commented 4 years ago

I upgraded my Blazor webassembly project to .Net5 RC2 (from .Net5 RC1) and I did notice that month names for my (Bosnian) ui culture are wrong.

Here is steps to reporduce:

In Main metoh of Program class I do set cultures to Bosninan

            CultureInfo.CurrentCulture = new CultureInfo("bs");
            CultureInfo.CurrentUICulture = new CultureInfo("bs");
            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("bs");
            CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("bs");

On any razor page when I try to get long date:

<p>Current UI Culture: <strong>@CultureInfo.CurrentUICulture.DisplayName</strong></p>
<p>Current Culture: <strong>@CultureInfo.CurrentCulture.DisplayName</strong></p>
<p>Sada je  @DateTime.Now.ToLongDateString() </p>

image

mkArtakMSFT commented 4 years ago

@lewing FYI

ghost commented 4 years ago

Tagging subscribers to this area: @tarekgh, @safern, @krwq See info in area-owners.md if you want to be subscribed.

lewing commented 4 years ago

/cc @EgorBo @steveisok

EgorBo commented 4 years ago

@lewing what is the strategy to address such issues? Just add the missing locales? bs is not presented in the list of locales we support (and neither in https://developer.chrome.com/webstore/i18n)

lewing commented 4 years ago

That is a different issue. The culture data is split up to save space so you can't just load any culture at runtime and expect it to work. You should be able to enable that full culture list by setting <BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData> in your csproj

/cc @pranavkm

lewing commented 4 years ago

@EgorBo I think we may just need to document things

adopilot commented 4 years ago

That is a different issue. The culture data is split up to save space so you can't just load any culture at runtime and expect it to work. You should be able to enable that full culture list by setting <BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData> in your csproj

/cc @pranavkm

I apologies,I did delete my comment.

EgorBo commented 4 years ago

@lewing it's documented here https://docs.microsoft.com/en-us/dotnet/standard/globalization-localization/globalization-icu#icu-on-webassembly (has a link to list of supported locales)

pranavkm commented 4 years ago

Yeah, I didn't realize the app was initializing a new culture. We should probably call that out in our docs.

safern commented 4 years ago

@lewing it's documented here https://docs.microsoft.com/en-us/dotnet/standard/globalization-localization/globalization-icu#icu-on-webassembly (has a link to list of supported locales)

I think we should add a more detailed description on the options to enable a full globalization experience, like the MSBuild property that @lewing pointed out here, does that make sense?

cornem commented 4 years ago

I'm experiencing the same after upgrading to RC2. However, the culture I'm using is nl, which is listed in the icu/optimal.json file. However, it's doesn't appear to be loaded.

What I'm doing: DateTime.Today.ToString("dddd d MMMM yyyy", CultureInfo.CreateSpecificCulture("nl")), which prints Thursday 15 October 2020 instead of the localized version.

lewing commented 4 years ago

@cornem is that with <BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData> in your .csproj and what language is your browser set to?

cornem commented 4 years ago

No, is that required now?

On Thu, Oct 15, 2020, 5:35 PM Larry Ewing notifications@github.com wrote:

@cornem https://github.com/cornem is that with

true

in your .csproj?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dotnet/runtime/issues/43398#issuecomment-709408036, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4LJPPY3LILLNKQSM2KSB3SK4JDXANCNFSM4SQ2GJHA .

lewing commented 4 years ago

@cornem by default Blazor loads a small subset of culture data based on the browser's current language setting. That option tells blazor to load a larger subset of cultures that is intended to mirror the cultures the browser supports.

pranavkm commented 4 years ago

Btw, I've added a note about this in our docs:https://docs.microsoft.com/en-us/aspnet/core/blazor/globalization-localization?view=aspnetcore-5.0#blazor-webassembly. It should take another day for the website to update.

CoffeeStainJo commented 3 years ago

I'm having the same issue for Norwegian, Bokmål (Norway)” (nb-NO).

To Reproduce: Create a Blazor WebAssembly hosted app (.net5.0) -- ASP.NET Core version: 5.0.102 image Is set in Program.cs

image Is configured in .csproj

image Is added in index.html

image Does not include the norwegian codes nb-no and DateTime.Now.ToString() returns image image

ilonatommy commented 2 years ago

Merging with issue for Norwegian: https://github.com/dotnet/runtime/issues/53239. It turns out that on the current whitelist all the locales reported in both issues are missing, so it looks like a duplicate.