Aspnetboilerplate: How can I use localized string in DisplayAttribute?

Created on 1 Jul 2018  ·  1Comment  ·  Source: aspnetboilerplate/aspnetboilerplate

dear,
I have a select input and Language enum, how can I use abp resource on DisplayAttribute?
《select asp-items="@Html.GetEnumSelectList(typeof(Language))"></select 》 public enum Language { [Display(Name="localized string here")] Javascript, CSharp }

question

Most helpful comment

ABP framework does not have a ready-made way to achieve it.

You can define the Key of the language.
Example:

```c#
public enum Language
{
[Display(Name="Language.Javascript")]
Javascript,

[Display(Name="Language.CSharp")]
CSharp

}
```

Then use ABP to localize the language when taking enumeration value strings.

GetEnumSelectList doesn't seem to support too many customizations, maybe you need to implement it yourself.

>All comments

ABP framework does not have a ready-made way to achieve it.

You can define the Key of the language.
Example:

```c#
public enum Language
{
[Display(Name="Language.Javascript")]
Javascript,

[Display(Name="Language.CSharp")]
CSharp

}
```

Then use ABP to localize the language when taking enumeration value strings.

GetEnumSelectList doesn't seem to support too many customizations, maybe you need to implement it yourself.

Was this page helpful?
0 / 5 - 0 ratings