-
Notifications
You must be signed in to change notification settings - Fork 846
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
Add a Culture
parameter on components for the default templates
#206
Comments
I think we won't implement this as there are supported ways to change the current culture in an ASP.NET Core application which work. Yes they require a reload but this is not such a big problem. The Startup.cs file of the Sample application contains commented code which can be used to set the current application culture. I have linked a screenshot showing this in action in this comment: #229 (comment) |
This turned out to be a problem when certain conditions are met (static classes and events - more here. We are reopening the issue and will accept pull requests. |
Thanks, I'll try to work on a PR, but can't make promises with the timeframe. Would it be ok, if, apart from a |
If it is not too much of a hassle - why not. It would probably require another property though ...
|
@akorchev I've made a PR. Sorry but I don't typically contribute code to OSS and I'm not sure the guidelines for making one and if that's correct. If you want me to review or test anything (I've just ran the tests as they were), please tell me |
Is your feature request related to a problem? Please describe.
When changing the Cutlure dynamically on a page (without reloading, thus, without changing the renderer thread's
CurrentCulture
/CurrentUICulture
), you cannot reliably change the renderer's synchronization context Culture, so async calls (orInvokeAsync()
) may have a different Culture.I've made a feature request for Blazor to include this capability here: dotnet/aspnetcore#35965
When you show the value or make binding yourself in the template you can use
.ToString(MyCulture)
or@bind-Value:culture="@MyCulture"
if needed, but components like theRadzenDataGrid
, orRadzenDropdown
, etc., where you don't bind directly (instead, you specify a type and a property name), always use the thread's culture on their default templates, so if you want a different culture, you need to specify the wholeTemplate
for every column, or dropdown template, etc., which is really inconvenient.Describe the solution you'd like
Have a parameter on those components of type
CultureInfo
to specify the default culture on the component, e.g.:<RadzenDataGrid Culture="@MyCulture">
, so that it takes it into account in the default templates (and it does.ToString(Culture)
when rendering, instead of justToString()
-or nothing, which callsToString
with theCurrentUICulture
format provider).It could use
CultureInfo.CurrentUICulture
if not specified, so it would not break any existing code.Additionally, default in-component templates for reflection-based rendered components (where you specify the type and the property name, instead of binding directly) would need to be revised to make use of that parameter.
The text was updated successfully, but these errors were encountered: