localization best practice

Thread is closed for posting
2 posts, 0 answers
  1. Michael Fuchs
    Michael Fuchs avatar
    3 posts
    Member since:
    Apr 2005

    Posted 06 May 2009 Link to this post

    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

  2. Alexander
    Alexander avatar
    727 posts

    Posted 08 May 2009 Link to this post

    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.

    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.
Back to Top