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

Pseudo-locales don't work in Blazor WebAssembly #42258

Closed
1 task done
uecasm opened this issue Mar 9, 2022 · 16 comments
Closed
1 task done

Pseudo-locales don't work in Blazor WebAssembly #42258

uecasm opened this issue Mar 9, 2022 · 16 comments
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

@uecasm
Copy link

uecasm commented Mar 9, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

After creating and publishing resources for qps-ploc and setting the default thread locale to it, Blazor WebAssembly's IStringLocalizer will render the default language instead. Other languages work as expected.

Expected Behavior

The qps-ploc locale should work as well (as should the other pseudo locales).

Steps To Reproduce

https://github.com/uecasm/pseudo-wasm

This is just the default blazorwasm template with localization added from the tutorial.

Edit Program.cs and comment in exactly one of the culture lines to see differences in behaviour. With es-ES selected, it displays the Spanish translation as expected. With either of the others, it displays the default resources.

In particular it does not show the qps-ploc translation when that is selected, even though the resources DLL is generated and is included in the blazor.boot.json manifest.

Exceptions (if any)

No response

.NET Version

6.0.200

Anything else?

https://stackoverflow.com/questions/71376446/pseudo-localization-in-blazor-webassembly

Visual Studio Code 1.65.0

.NET SDK (reflecting any global.json):
 Version:   6.0.200
 Commit:    4c30de7899

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19041
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.200\

Host (useful for support):
  Version: 6.0.2
  Commit:  839cdfb0ec

.NET SDKs installed:
  2.1.511 [C:\Program Files\dotnet\sdk]
  6.0.200 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
@javiercn
Copy link
Member

@uecasm thanks for contacting us.

  • Do those pseudo-locales work in .NET?
  • Does localization work in your app if you use a different locale?

@ghost
Copy link

ghost commented Mar 10, 2022

Hi @uecasm. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@javiercn javiercn added the feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly label Mar 10, 2022
@uecasm
Copy link
Author

uecasm commented Mar 10, 2022

Yes, they both work perfectly fine in a .NET Framework or .NET 6 Console app. And I already said that the Spanish locale is working fine in this project, it's only the pseudo locale that's not working.

@javiercn
Copy link
Member

@uecasm thanks for the clarifications.

I think this might be a runtime issue then with regards to globalization.

@javiercn javiercn transferred this issue from dotnet/aspnetcore Mar 11, 2022
@yfranz
Copy link

yfranz commented May 25, 2022

I'm dealing the same problem. Is there any work around for it?

@uecasm
Copy link
Author

uecasm commented May 25, 2022

The workaround that I'm using in the interim is using a different locale for the pseudotranslation. Specifically, I'm using en-UM, since it's an English locale that seems not super likely to actually be set in someone's browser preferences. But there's a higher risk of accidentally catching people unawares than with the real pseudolocales.

@marek-safar marek-safar removed the feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly label May 25, 2022
@ghost
Copy link

ghost commented May 25, 2022

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?

  • I have searched the existing issues

Describe the bug

After creating and publishing resources for qps-ploc and setting the default thread locale to it, Blazor WebAssembly's IStringLocalizer will render the default language instead. Other languages work as expected.

Expected Behavior

The qps-ploc locale should work as well (as should the other pseudo locales).

Steps To Reproduce

https://github.com/uecasm/pseudo-wasm

This is just the default blazorwasm template with localization added from the tutorial.

Edit Program.cs and comment in exactly one of the culture lines to see differences in behaviour. With es-ES selected, it displays the Spanish translation as expected. With either of the others, it displays the default resources.

In particular it does not show the qps-ploc translation when that is selected, even though the resources DLL is generated and is included in the blazor.boot.json manifest.

Exceptions (if any)

No response

.NET Version

6.0.200

Anything else?

https://stackoverflow.com/questions/71376446/pseudo-localization-in-blazor-webassembly

Visual Studio Code 1.65.0

.NET SDK (reflecting any global.json):
 Version:   6.0.200
 Commit:    4c30de7899

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19041
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.200\

Host (useful for support):
  Version: 6.0.2
  Commit:  839cdfb0ec

.NET SDKs installed:
  2.1.511 [C:\Program Files\dotnet\sdk]
  6.0.200 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Author: uecasm
Assignees: -
Labels:

arch-wasm, untriaged, area-VM-meta-mono

Milestone: -

@ghost ghost removed the untriaged label May 25, 2022
@ilonatommy
Copy link
Member

@BrennanConroy, @sebastienros it seems like some issue connected with Microsoft.Extensions.Localization. What do you think?

@lewing
Copy link
Member

lewing commented Jun 10, 2022

@javiercn can you help us take a look at this

@javiercn
Copy link
Member

@lewing I can try, but I'm not familiar with the area at all.

@ilonatommy do we see a delta between the behavior on .NET core vs .NET on wasm for Microsoft.Extensions.Localization?

@ilonatommy
Copy link
Member

Yes, we do. For Blazor Server with asp NET core 3.1 runtime and Blazor Server with NET 7 runtime it's working fine. For Blazor Wasm with NET 7 runtime the behavior is as described in the issue. It's definitely something that Wasm is doing differently.

@javiercn javiercn transferred this issue from dotnet/runtime Jun 17, 2022
@javiercn
Copy link
Member

@ilonatommy thanks for the additional details.

I have moved the issue to the asp.net core repo so that we can take a look.

@javiercn javiercn added area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly labels Jun 17, 2022
@mkArtakMSFT
Copy link
Member

@ericstj doesn't your team own the Microsoft.Extensions.Localization library? Can you help with this investigation?

@ericstj ericstj removed their assignment Jun 21, 2022
@ericstj
Copy link
Member

ericstj commented Jun 21, 2022

We don't own any of the Extensions components that remained in aspnetcore, those were retained by ASP.NET.

@mkArtakMSFT mkArtakMSFT added this to the .NET 7 Planning milestone Jun 27, 2022
@ghost
Copy link

ghost commented Jun 27, 2022

Thanks for contacting us.
We're moving this issue to the .NET 7 Planning milestone for future evaluation / consideration. Because it's not immediately obvious that this is a bug in our framework, we would like to keep this around to collect more feedback, which can later help us determine the impact of it. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@mkArtakMSFT mkArtakMSFT added bug This issue describes a behavior which is not expected - a bug. and removed investigate labels Jun 27, 2022
@ilonatommy
Copy link
Member

ilonatommy commented Dec 20, 2022

Cannot reproduce anymore on the project that was provided. It is working in dotnet 7. and dotnet 6 for both: empty ResourcesPath and specified by user:

builder.Services.AddLocalization(options => { options.ResourcesPath = "Resources"; });

image

@ghost ghost locked as resolved and limited conversation to collaborators Jan 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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