-
Notifications
You must be signed in to change notification settings - Fork 478
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
Support for HelpText localization with ResourceType property. #356
Conversation
Looks good, but I have one question... (wihtout looking myself) isn't there already a Localizable attribute in System.ComponentModel that can be used? Or is the reason for the "new" attribute here in the library, because of Netstandard/netcore/netfx differences? |
This localize HelpText property of Option/Value attribute throw resources. This is not same as LocalizableAttribute from System.ComponentModel. Usage is inspired from DisplayAttribute (https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.displayattribute). Infrastructure helper LocalizableAttributeProperty is used only once for HelpText property. Usage is: and create EmployeeResx resource, so HelpText will be shown localized. |
Is this something that is still being considered? |
Localization is required as posted in the issues #321, #361. Localizing the library can be done by localizing all the constant strings used in the library like "Required" , "Default", .. and so on including the error messages. What is your suggestion based on the above text? |
I must be missing something. I was looking at this PR conversation because I was unable to use a resx file with English strings to populate the helptext field in the options attribute, because it is an attribute and resx file values are not constants. This post seemed to solve that problem, but I'm happy to do it another way if you could help me connect the dots. I can provide a code example of that would help. |
@gkelling |
Using the example above with a few modifications, we have this. I want to set "Enter your last name." using a resx file. Any help would be appreciated. |
The error stating you must use a constant is expected because it's used in Attribute properties. Steps to localize Console application:
I find PR of @tkouba define HelpText using the resource file: ResourceType= typeof(EmployeeResx)
@tkouba |
@moh-hassan My concern is that the class is generated when the project is compiled and thus the strings are set to the language that the machine compiling is using. There is no localization determined at runtime, where as the solution presented by @tkouba would utilize the resx framework for this. Or were you suggesting that a runtime text template be used? I was under the impression those were only used for text manipulation, not code generation. |
The provided solution (work around) localize the Application at compile time due to the limitation of Attribute'Properties of using constant expression. I start an integration test with this PR and there are some fail of test cases and I try managing to fix it with the author of other feature. |
|
@moh-hassan |
Closing issue #330