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

Localization of Property Grid

6 Answers 329 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 07 Apr 2014, 02:03 PM
I wanting to utilize the PropertyGrid in a application. I have a requirement to support multiple languages. What is the best approach to localize the strings displayed to the user? I am referring the Property Names, and Property Descriptions. I would also like to categorize properties and would like the categories translated.

I have tried an approach I found on CodeProject, but it is designed for WinForms and not WPF. It uses a GlobalPropertyDescriptor which is derived from PropertyDescriptor. This class overrides the Name, DisplayName, and Description properties to retrieve localized strings from string tables. The problem to the approach is the getters for the DisplayName and Description properties are never accessed. The Name property is accessed.

Each class displayed in a PropertyGrid inherits from a common base class that implements an ICustomTypeDescriptor. Most of the what happens here is in the GetProperties functions.

Bottom line is this approach is not working for the WPF version of the PropertyGrid and I am looking for some guidance.
Any assistance is greatly appreciated.

6 Answers, 1 is accepted

Sort by
0
Robert
Top achievements
Rank 1
answered on 08 Apr 2014, 06:15 PM
I have added the following attribute to one of my properties.

[Display(ResourceType = typeof(DisplayResources), Name = "VerificationTime", Description = "VerificationTimeDescription", GroupName = "VerificationTimeGroup")]

I have string table for each support language.
DisplayResources is where my string tables are.
VerificationTime, VerificationTimeDescription, and VerificationTimeGroup all exists as Names each of my string tables. Each name in the string table has the desired Value to be displayed.

Name is the only string that is correctly translated, leading me to believe the access to the resource is correct.
Why can't I localize Description, and GroupName?

0
Dimitrina
Telerik team
answered on 10 Apr 2014, 10:54 AM
Hello,

The built-in localization for RadPropertyGrid supports localizing just two values. As to it, you can check our online documentation on Localization for RadPropertyGrid  and the general article on the built-in Localization mechanisms.
 
Apart from that you can also apply your own localization through data annotations attributes. This is what you are actually trying to do. I have attached a test solution demonstrating how this can be achieved.

I hope the solution works for you.

Regards,
Didie
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Robert
Top achievements
Rank 1
answered on 10 Apr 2014, 07:14 PM
Thank you for your help. Your solution works perfectly.

In my solution I am still having problems. There are some subtle differences, but basically I ended up using the same approach as in your solution. Here are the differences.
I am using a trial version of 2014.1.331.45.
My ViewModels are in a separate class library. I using the resources from that library.
I am using a fair amount of inheritance in my view models, but one of the properties has the attributes applied to the actual class I am binding to.

In my solution the Name works correct, but the Description and GroupName do not.
Setting break points on the VerificationTime, VerificationTimeDescription, and VerificationTimeGroup properties of my Resources class I can see that VerificationTime getter is accessed, but the others are not.

I was going to send my project Attach files does not support zip files.
0
Dimitrina
Telerik team
answered on 11 Apr 2014, 01:42 PM
Hello,

The trial version should not make any difference in the behavior you get. Would you please open a support ticket and send us the demo solution?
That way we will check it locally and advise further.

Regards,
Didie
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Robert
Top achievements
Rank 1
answered on 14 Apr 2014, 05:36 PM
If the RadPropertyGrid is being used to edit a collection of objects the localization does not work as expected. In my case the Name of the property is localized but not the description or group name.

It's too bad, because I really need the multiple object PropertySetModes and the localization. Each work, but not at the same time. 
0
Dimitrina
Telerik team
answered on 15 Apr 2014, 10:58 AM
Hello,

I am glad to let you know we found the reason for this behavior and we managed to resolve the issue. The fix is expected to be included in the next latest internal build.

Regards,
Didie
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
PropertyGrid
Asked by
Robert
Top achievements
Rank 1
Answers by
Robert
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or