-
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 Localization Roadmap? #22178
Comments
Thanks for contacting us. |
It's not because of being in a different project; within the same project it also crashes.
I have a repro project, can I send it to you via email? There's also the fact that there's no support for displaying the field name in a label; although such a Label For component can be implemented manually. |
@mysteryx93 we don't need a private app for this - just a minimal repro app hosted in GitHub is what we're looking for. |
I have a minimal repro but won't put it on GitHub |
@mysteryx93 to clarify, by minimal repro we refer to the minimum required changes on top of a new project, which will reproduce the issue. We are not interested nor we have enough resources to look into customer projects. |
@mysteryx93 You can roll your own localizer. I'm using Json files and custom attributes to make it work in Blazor. I'm using translation over multiple projects.
You can design your own strategy. I use one translation file (per language) per 'Area'.
Same here, design your own strategy. If you don't change your keys, create an 'override' mechanism
You can share translations by using the same type. Merge multiple json files to share translations between different area's (base translation + custom translations). [Translation("Translation\\Shared")]
public class SharedTranslation
{
//Dummy class to group localization, can stay empty
}
[Translation("Translation\\Button")]
public class ButtonTranslation
{
//Dummy class to group localization, can stay empty
}
[Translation("Translation\\ValidationRules")]
public class ValidationRulesTranslation
{
} I used https://github.com/rwwilden/AspNet5Localization for inspiration |
@JvanderStad, it doesn't seem your solution has any reference to DataAnnotations and DisplayAttribute to use and localize them |
ok here's a minimal repro |
@SteveSandersonMS Is there a way to use my custom localizer factory? I also read: Thank you |
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. |
The original issues described here no longer seem to apply, so I'm going to close this. If anyone still has issues in this area, could you please post a new issue describing your scenario directly? Thanks!
You can have whatever granularity you want. Have a single file for your entire application if you want.
True. This is innate to how resx works and not something we control in
Sounds like a restatement of the first point.
DataAnnotations validation now does read localization from attributes. Working Blazor example: https://github.com/SteveSandersonMS/CarChecker/blob/master/Client/Pages/Index.razor#L38 |
According to this article,
IStringLocalizer is supported, and that's about it. The problem with IStringLocalizer is that
I tried adding localization to validation attributes.
First with a custom DisplayNameAttribute with built-in localization. DataAnnotations Validation doesn't read this attribute though.
Then with Display(Name="FirstName", Type=typeof(Resources)), but it made the application crash (at least when the resource is in a different project).
So it seems there's really not much localization support at all for now... better leave out localization altogether.
I don't really need localization anyway, but wanted to structure my code in clean way that would make allowing localization easy. What are the plans for Blazer localization support in .NET 5? I'd be better to structure the code in a way that would be compatible for that.
IStringLocalizer really doesn't seem like a good solution... does it even work to localize DisplayAttribute for validation messages?
The text was updated successfully, but these errors were encountered: