This is a migrated thread and some comments may be shown as answers.

Custom data annotation (for internationalization)

4 Answers 179 Views
DataFilter
This is a migrated thread and some comments may be shown as answers.
OBollmann
Top achievements
Rank 2
Iron
OBollmann asked on 24 Sep 2010, 11:07 PM
Hi,

with data annoations (DisplayAttribute) it is possible to create custom descriptions for the filtered properties. But unfortunately the DisplayAttribute is sealed. So it is not possible to inherit from this Attribute to implement internationalization from resource files. (I did something equal with the DescriptionAttribute which is not sealed). Is it possible to create custom property descriptions in a different way? Perhaps with ItemPropertyInfo class? At first sight it seems that it is not possible. In constructor of ItemPropertyInfo you can set name, type and descriptor. Name is obviously used for creating FilterDescriptors so the name must represent the real path to the property and could not be a user readable name. The type is the type ;-) And the descriptor is a PropertyInfo instance which contains the real name of the property again. Is there a way to accomplish my request?

Best regards,
Oliver

4 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 28 Sep 2010, 07:32 AM
Hello OBollmann,

We will obsolete the usage of ItemPropertyInfo's with the Q3 release, just for the reason you have mentioned -- they are hard to create and even harder to modify.

We will replace them with our own ItemPropertyDefinition class, which will have the following properties:

- PropertyName: the name of the prop, can be complex nested prop, i.e. with dots.
- PropertyType: well, the type
- DisplayName: what the UI will show -- I think this will be perfect for localization.

These objects will be DependencyObjects and you will be able to bind to all of their props.

Do you think that this will solve your requirements?

Kind regards,
Ross
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
OBollmann
Top achievements
Rank 2
Iron
answered on 28 Sep 2010, 12:14 PM
That would be cool!! I will give it a try!

Best regards,
Oliver
0
srecov
Top achievements
Rank 1
answered on 11 Aug 2013, 01:15 PM

 

 

Hi,

I hope your solution is already in production. Wuld you please give me an example how to use localization in data annotation. Both annotations are from standard silverlight business template using RIA. I am replacing standard controls with telerik. I am already using ResourceManager telerik localization for key strings and it is working ok. I do not know what type of resource I have to write. When I use my new KeyStrings.resx  for Telerik localization, I get an error: "Cannot retrive property 'Name' because localization failed."

regards
Srečo   

// silverlight project code behind for login control
[Display(Name = "PasswordLabel", ResourceType = typeof(RegistrationDataResources))]
 
 
//web project services metadata...server side validation
[Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationErrorResources))]

 

 

 

0
Dimitrina
Telerik team
answered on 15 Aug 2013, 01:18 PM
Hello,

We have already replied to your support thread on the same matter and I am also pasting our answer below.

The provided Data Annotation seems to work at our side, just make sure that you have the string added in the .resx file. In order to make the .resx files available for both the Web project and the Silverlight project, you should add them inside the Web project and link them in the client project, the approach is explained in details in the following blog post:
http://blogs.msdn.com/b/brada/archive/2010/03/22/silverlight-4-ria-services-ready-for-business-localizing-business-application.aspx
 

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
DataFilter
Asked by
OBollmann
Top achievements
Rank 2
Iron
Answers by
Rossen Hristov
Telerik team
OBollmann
Top achievements
Rank 2
Iron
srecov
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or