dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.12k stars 1.73k forks source link

Maui Blazor input display language problem #9928

Closed gm391 closed 1 year ago

gm391 commented 2 years ago

Description

Hello,

In my blazor Maui app with os language Fr, CultureInfo.DefaultThreadCurrentCulture and CultureInfo.DefaultThreadCurrentUICulture are fr-Fr but in the razor pages inputs display language in an EditForm component or a form component is always English. For exemple with a datepicker expected result is french language for the months and date format is dd/mm/yyyy.

The observed result is months in english and date format is mm/dd/yyyy.

With a blazor webapplication language and format are ok.

Thanks a lot for your help and i hope this issue is not already known.

Steps to Reproduce

1-> Create a new razor maui project 2-> in the razor page index add :

<EditForm Model="date">
    <InputDate id="date" @bind-Value=date/>

</EditForm>
<form>
    <input type="date"/>
</form>

@* add below lines to check the value*@
@CultureInfo.CurrentUICulture
@CultureInfo.CurrentCulture
@CultureInfo.DefaultThreadCurrentCulture
@CultureInfo.DefaultThreadCurrentUICulture

@code{    
    public DateTime date { get; set; }
}

Run the app in debug mode and check result

Link to public reproduction project repository

https://github.com/gm391/Maui-Blazor-inputs-language-Bug.git

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

windows SDK 10.0.19041.0

Did you find any workaround?

no workaround found

Relevant log output

no log
SteveSandersonMS commented 2 years ago

Thanks for reporting this, @gm391.

As things stand, with WebView2, it looks like it's up to you to set the language property on CoreWebView2EnvironmentOptions when the webview is being created: https://github.com/MicrosoftEdge/WebView2Feedback/issues/833#issuecomment-892334635

This is already possible but unfortunately not yet documented. We're tracking the need to add docs at https://github.com/dotnet/AspNetCore.Docs/issues/26948

ghost commented 2 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

gm391 commented 2 years ago

Hello,

thank you for your answer but i'm a little lost, sorry for my poor level.

I don't know how to set set the language property on CoreWebView2EnvironmentOptions. CoreWebView2Environment class is not found by visual studio and if i install the nuget package Microsoft.Web.WebView2 i have an error with code cs0433 CoreWebView2EnvironmentOptions exists in Microsoft.Web.WebView2.Core and Microsoft.WinUI

I found some help for xamarin projects but not for Blazor Maui.

Thank you for your help

danroth27 commented 1 year ago

We should follow up with the WebView2 folks to understand if they should be picking up the .NET culture without additional configuration.

mkArtakMSFT commented 1 year ago

Closing as this has been already documented and the issue tracking the doc work is not yet updated. We'll fix that soon. @danroth27 I think it's worth following up with the WebView2 folks about the proposed feature that you had. Given, however, no further action is pending here, I'm closing.