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

Blazor WASM only relies on the current culture (current UI culture isn't respected) #56824

Open
1 task done
guardrex opened this issue Jul 16, 2024 · 0 comments
Open
1 task done
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-localization

Comments

@guardrex
Copy link
Contributor

guardrex commented Jul 16, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

This is essentially a dup of the unaddressed, closed issue filed by @SQL-MisterMagoo at Blazor WebAssembly Localization does not behave the same as Server side (dotnet/aspnetcore #25296) and a new issue that just arrived again on the docs repo at Can we have more details for the note, please? (dotnet/AspNetCore.Docs #33077).

cc: @hishamco @voroninp

Expected Behavior

It came to light several years ago via a docs issue from @SQL-MisterMagoo that resource loading is only based on the current culture in the WASM culture provider ...

https://github.com/dotnet/aspnetcore/blob/main/src/Components/WebAssembly/WebAssembly/src/Hosting/WebAssemblyCultureProvider.cs#L65

Why doesn't Blazor WASM load resources for both current culture and current UI culture? I'm going to (at least temporarily) react to this with a doc update that has devs only set the current culture in Blazor WASM apps.

Chatting with @SteveSandersonMS offline, this might be a bug ...

I think we should be loading the localization resources for CurrentUICulture (and possibly also CurrentCulture if that’s needed to make formatting/parsing work correctly). Whereas like you point out, we only load for CurrentCulture.

The original issue was backlogged for work but closed without work by @SQL-MisterMagoo.

Steps To Reproduce

From the report of @SQL-MisterMagoo, one can follow our Statically set the client-side culture guidance using a different culture for current culture and current UI culture and with the client-side localization guidance for a culture that matches the current UI culture.

I've placed a repro app at ...

https://github.com/guardrex/Blazor-WASM-Loc-PU-Issue-56824

  1. The app configures the current culture and current UI culture to US English (en-us). Run the app and see the correct globalization and localization in the CultureExample1 and CultureExample2 components.
  2. In Program.cs, change the current UI culture to Spanish (es-es). CultureExample1 globalizes correctly to English, but CultureExample2 doesn't localize to Spanish.
  3. Change the current culture to Spanish. Now, both CultureExample1 and CultureExample2 globalize and localize correctly to Spanish, respectfully.

Exceptions (if any)

None

.NET Version

AFAIK, this is for all versions.

Anything else?

Looks like it came in here 👉 #20033 ... and I don't see discussion on the point of only setting current culture.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Jul 16, 2024
@mkArtakMSFT mkArtakMSFT added bug This issue describes a behavior which is not expected - a bug. feature-localization labels Jul 16, 2024
@mkArtakMSFT mkArtakMSFT added this to the .NET 10 Planning milestone Jul 16, 2024
@mkArtakMSFT mkArtakMSFT added the feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly label Jul 16, 2024
@guardrex guardrex changed the title Blazor WASM doesn't load loc resources unless the current culture and current UI culture are the same Blazor WASM only relies on the current culture (current UI culture isn't respected) Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-localization
Projects
None yet
Development

No branches or pull requests

2 participants