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 MAUI: Controls in BlazorWebView use the device's culture and not an application configured culture #4484

Closed
pranavkm opened this issue Feb 2, 2022 · 1 comment
Assignees
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView platform/android 🤖 t/bug Something isn't working

Comments

@pranavkm
Copy link
Contributor

pranavkm commented Feb 2, 2022

Description

Follow up to #2532. If an app configures a culture other than the device's default, Blazor uses it for binding, parsing and localization. However, the UI controls within the web view continue to use the device default culture.

Steps to Reproduce

  1. File -> New .NET MAUI Blazor app
  2. Update MauiProgram.cs to configure a culture e.g. CultureInfo.CurrentCulture = CultureInfo.CurrentUICulture = new CultureInfo("fr-FR");
  3. Add a date input field:
Input: input type="date" @bind="dateTime" />
Bound: @dateTime

Expected: The input appears using French localization
Actual: The bound value uses the French locale, but the input uses the device's culture.

Version with bug

Preview 12 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

n/a

Did you find any workaround?

No response

Relevant log output

No response

@pranavkm pranavkm added t/bug Something isn't working area-blazor Blazor Hybrid / Desktop, BlazorWebView labels Feb 2, 2022
@pranavkm
Copy link
Contributor Author

pranavkm commented Feb 3, 2022

Resolving this. Using DefaultThreadCurrentCulture instead of CurrentCulture does the right thing. My guess is that the WebView component is rendered from a different context and configuring CurrentCulture is not sufficient as it does not flow across Thread / async boundaries.

@pranavkm pranavkm closed this as completed Feb 3, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Mar 6, 2022
@mkArtakMSFT mkArtakMSFT added this to the 6.0.300-preview.14 milestone Mar 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView platform/android 🤖 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants