Skip to content

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

Open
@guardrex

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Priority:3Work that is nice to havearea-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.feature-blazor-wasmThis issue is related to and / or impacts Blazor WebAssemblyfeature-localization

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions