-
Notifications
You must be signed in to change notification settings - Fork 966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to humanize enums from resource strings #323
Comments
I personally don't think this is something you should drive through Humanizer. Humanizer's added value is that it can Humanize your enums and as a bonus point fetch the description from Description attribute when it diverges from the member name. If you don't use the humanized member names, then I'm not sure why you would need Humanizer at all! You could very easily wrap your |
Humanized string depends on current language. Rest of UI can be localized throw resources. Humanizer is to get some user-readable string from programmer-meaningful concept. There are localization for datetime, but how can I add localization for enum members? |
👍 |
With .NET 4.5 there is a DisplayAttribute with supports localization. |
IIRC DisplayAttribute doesn't work on enums. It's for classes and properties. |
It's also allowed on fields and works on enum members without problems. |
I like it @mexx. The other great thing about We can't remove the support for |
A problem
Firstly, if there are several localizations for product they are located in Resources.resx files. So string literals are being chosed depended on current locale.
So my current code now is like this:
resourceManager.GetString(stringToLocalize)
.I can't place it to an attribute because ones arguments must be a const.
Secondly, we can write convention like this for enums:
Question
Are there any way to use resource strings for enum humanization in current version?
Can I make pull request for it?
The text was updated successfully, but these errors were encountered: