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

Related issues

RiaanvE picture RiaanvE  Â·  3Comments

vnetonline picture vnetonline  Â·  3Comments

hitaspdotnet picture hitaspdotnet  Â·  3Comments

sylfree9999 picture sylfree9999  Â·  3Comments

satishsomani picture satishsomani  Â·  3Comments