0
tonid created
For example I have this DTO:
public class SampleDTO
{
[Display("SomeValue")]
public string SomeValue { get; set; }
}
How to achieve localization in display attribute? I know display attribute has resource parameter, but how to connect it in ABP implementation?
3 Answer(s)
-
0
Hi,
If you want to use like that, you can use Resource file as localization source. Add a new resource file and use it as you always do with ASP.NET MVC. ABP has no such a localization property currently.
-
0
In my test project, that was based on Abp 0.6.3 I used custom attributes for that (please check attached file).
Few notes on those:
- This was done before localization was moved to Core project, so localization source name was set using configuration, now You should be able to get it directly.
- There are Display and DisplayName attributes - Display attribute cannot be extended, so You will need to use DisplayName attribute.
- For localized validation attributes to work You will need to register them in You Global.asax:
DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(LocalizedRequiredAttribute), typeof(RequiredAttributeAdapter)); DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(LocalizedStringLengthAttribute), typeof(StringLengthAttributeAdapter));
- LocalizedDisplayName attribute can be used on enums also, original DisplayName attribute can not.
Hope that helps :) Attributes.zip
-
0
@hikalkan Thanks for your suggestion
@easyest Cool, I will try your attribute file and thanks for your help :)