Open ArneMancofi opened 2 years ago
I'm now facing this issue as my company is using english windows but german date and number formats. Mudblazor is using a dot as decimal separator while it should use a comma.
Is there any easy workaround?
Here is an example of the issue we have with culture en-DE
<h1>Culture Example 1</h1>
<p>
<b>CurrentCulture</b>: @CultureInfo.CurrentCulture
</p>
<h2>Rendered values</h2>
<ul>
<li><b>Date</b>: @dt</li>
<li><b>Number</b>: @number.ToString("N2")</li>
</ul>
<h2><code><input></code> elements that don't set a <code>type</code></h2>
<p>
The following <code><input></code> elements use
<code>CultureInfo.CurrentCulture</code>.
</p>
<ul>
<li><label><b>Date:</b> <input @bind="dt" /></label></li>
<li><label><b>Number:</b> <input @bind="number" /></label></li>
</ul>
<h2><code><input></code> elements that set a <code>type</code></h2>
<p>
The following <code><input></code> elements use
<code>CultureInfo.InvariantCulture</code>.
</p>
<ul>
<li><label><b>Date:</b> <input type="date" @bind="dt" /></label></li>
<li><label><b>Number:</b> <input type="number" @bind="number" /></label></li>
</ul>
<MudForm>
<MudNumericField @bind-Value="number" />
</MudForm>
@code {
private DateTime dt = DateTime.Now;
private double number = 1999.69;
}
Bug type
Other
Component name
No response
What happened?
MudBlazor\Utilities\BindingConverters\Converters.cs uses
CurrentUICulture
for defining the default culture used for date and number conversion:It is my impression that
CultureInfo.CurrentUICulture
is only supposed to be used for ResourceManager related operations for fetching localized text, etc., cf. the CultureInfo.CurrentUICulture documentation.Expected behavior
It seems to me that
CultureInfo.CurrentCulture
should be used instead, cf. the CultureInfo.CurrentCulture documentation:Reproduction link
https://try.mudblazor.com/snippet/QkGQOClZSiDJVuvJ
Reproduction steps
Oftentimes, the two values of
CultureInfo.CurrentUICulture
andCultureInfo.CurrentCulture
are identical, so the effect of usingCultureInfo.CurrentUICulture
may go unnoticed. However, sometimes they may differ, for instance if Windows applications should display English text, but dates and numbers should be formatted using, say, Danish, German or French culture.Relevant log output
No response
Version (bug)
6.0.14
Version (working)
No response
What browsers are you seeing the problem on?
Chrome
On what operating system are you experiencing the issue?
Windows
Pull Request
Code of Conduct