-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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] Data annotations localization support #12158
Comments
Thanks for contacting us, @qw-34. |
Please also add support for |
will this be supported in 3.1? we also need full multi-language support for server-side application texts, data annotations validations, etc |
Localization is now supported in Blazor, using
DataAnnotations are not really supported though. After some quick investigation, my conclusion is that the It could be implemented there by injecting But you need to create adapters to handle the localization of specific data annotations, like in MVC: It might be a bigger task than expected. There is also an experimental |
Is there any schedule to support Data Annotations localization in Blazor ? Without them Blazor apps are fully localized in a language, but the standard data annotation errors remain still in English....this "double language" is not great from the user perspective. Think about this feature, it's important for every application. |
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. |
With .net Core came the new "way" of Translating strings, using the IStringLocalizer is the new sensation!! |
Thanks for contacting us. We're moving this issue to the |
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. |
This belonged in Blazor version 1.0... we are 5 YEARS from that date. This issue absolutely blocks Blazor from being used for small projects that needs to support a language different than en-US. On larger projects of-course you can choose shoot yourself in the foot and not use dataannotations, or you can have enough processes in place to make sure that everyone uses your custom dataannotations with your project level translations and have build processes setup to make sure that noone uses the built-in ones, all major undertakings in themselves. |
i'm using mudblazor as designframework, there is alternatively instead of , there dataannotations is done in the razor page, so i could implement formvalidation multilingual for me.. i dont think anything will ever happen here with classic annotations :( maybe u can be inspired ;) https://mudblazor.com/components/form#simple-form-validation |
Thanks for contacting us. We're moving this issue to the |
Really? This basic functionality is now laying in your backlog for five years... |
In my case, I have custom localization service (like
IStringLocalizer
), that retrieve localization from database for user-specific culture. User culture configures in user settings, that may changes in application runtime, i.e. without page reload.Service registers as scoped, i.e. each user have own
ILocalizationService
with own specific culture settings.In components this works great, just inject service.
Of course, this does not work in standard case of using data annotation attributes. For example:
Data annotation attributes can be provided with custom type with localized strings. Something like this:
Main problem of this approach is that localized strings in
LocalizationResources
must be as static properties. So we cant directly inject user-specificILocalizationService
. But we can try get user-specificILocalizationService
viaFunc<ILocalizationService> LocalizationServiceProvider
that can be configured, for example, inConfigure()
method:Of course, this does not work, because of scope of
serviceProvider
inConfigure()
method differs from user-specific scopes. In order for this approach to work it is necessary inLocalizationResources.LocalizationServiceProvider
uses some kind of context that will provide user-scopedIServiceProvider
to resolve user-specificILocalizationService
.So, at this moment, in server-side Blazor is exists any method to localize the data annotation attributes in non-resx scenarios? Have a plan to implement its in future?
The text was updated successfully, but these errors were encountered: