Hello!
I need to use localization for my enums with annotation to use with dropdownlists, but i cant figure it out.
Aaron has described it like this:
public enum OrderByOptions
{
[AbpDisplayName(MyConsts.LocalizationSourceName, "OrderByOptions.Default")]
Default,
[AbpDisplayName(MyConsts.LocalizationSourceName, "OrderByOptions.PriceLowToHigh")]
PriceLowToHigh,
[AbpDisplayName(MyConsts.LocalizationSourceName, "OrderByOptions.PriceHighToLow")]
PriceHighToLow,
[AbpDisplayName(MyConsts.LocalizationSourceName, "OrderByOptions.MostRecent")]
MostRecent
}
Copied from this post: https://stackoverflow.com/a/46642292
But i get validation error saying that this attribute is not valid on this declaration type, only valid on 'class, method, property, indexer, event' declarations.
Any solution? Thanks in advance!
5 Answer(s)
-
0
You can take look this:https://github.com/aspnetboilerplate/aspnetboilerplate/issues/3573
-
0
Any idea how to customize the taghelper GetEnumSelectList to support that functionality and make localization possible?
-
0
You can define "Enum_{Enum_Name_Here}_{Enum_Value_Here}" localization keys for your enums. Something like "Enum_OrderByOptions_PriceLowToHigh".
-
0
ismcagdas, can you please provide some example, i dont really understand how to use your example?
I have tried to add:
<text name="Enum_Test_Type_Summer">Sommar</text>
For this Enum...
public class MyEnums { public enum Test_Type { [Display(Name = "Summer")] Summer } }
But the strings will not be localized.....the values in the dropdown becomes: "Summer" instead of the wanted "Sommar"
-
0
@pointlevel
Could you also share generated cshtml code ? Maybe I understand you wrong at the first place.