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

localization best practice

1 Answer 56 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael Fuchs
Top achievements
Rank 1
Michael Fuchs asked on 06 May 2009, 04:18 PM
Hello Forum

I'm indecisive on how to model a business object that should support localization and work with OpenAccess.

For example I would like to create an object "product" with properties like "product name", "description", "price", "supplier" and so on.
A few properties require localization, e.g. the "product name".

What is the best practice to reflect this requirement within my business object?
Store all different product names in a hashtable and decide within the "get" of the product name property which culture to return?

Best regards
Michael

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 08 May 2009, 04:01 PM
Hi Michael Fuchs,

Yes, the hashtable approach should work fine. However, there is something that you may have to think about. If you expose the hashtable by a string property, you will be able to search for a product by its name only in the current locale. And you will probably have to create an additional method for adding new key-value pairs. Having that said maybe it is appropriate to have an additional property that exposes the hashtable with its real type. For example, if you are using a field of type Dictionary<string, string>, you can execute a Linq query that will search for a string in all available locale values of a product:
List<Product> products = scope.Extent<Product>().Where(x => x.ProductNameDictionary.Values.Any(str => str.Contains("abc"))).ToList(); 
In parallel to that you can have the string property that returns the value according to the current locale. It is up to you to choose what behavior you need, it should work both ways. Hope that helps.

Greetings,
Alexander
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
General Discussions
Asked by
Michael Fuchs
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or