CommunityToolkit / CommunityToolkit/dotnet
Incorrect parameter localization via the Display attribute during validation
- Dominant language
- C#
- Stars
- 3.8k
- Forks
- 400
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the bug
When trying to add localization for an attribute through the following code:
```cs
[ObservableProperty]
[NotifyDataErrorInfo]
[Required(
ErrorMessageResourceType = typeof(ValidationResources),
ErrorMessageResourceName = nameof(ValidationResources.Required))]
[Display(
ResourceType = typeof(ValidationResources),
Name = nameof(ValidationResources.Username))]
private string username = string.Empty;
```
localization works correctly for the message itself, but not for the field name set via Display. I assume that there is some kind of cache that blocks the change of locale.

[issue.zip](https://github.com/CommunityToolkit/dotnet/files/9457545/issue.zip)
### Regression
_No response_
### Steps to reproduce
```text
Run example solution and change language
```
### Expected behavior
parameter display name should change correctly when changing language
### Screenshots
_No response_
### IDE and version
VS 2022
### IDE version
17.3
### Nuget packages
- [ ] CommunityToolkit.Common
- [ ] CommunityToolkit.Diagnostics
- [ ] CommunityToolkit.HighPerformance
- [X] CommunityToolkit.Mvvm (aka MVVM Toolkit)
### Nuget package version(s)
8.0.0
### Additional context
_No response_
### Help us help you
No, just wanted to report this
Contributor guide
Assessment
This issue has not been assessed yet.