I have posted a question about multilanguage database design here,
[]http://stackoverflow.com/questions/929410/what-is-best-practices-for-multilanguage-database-design
I like Martin's suggestion,but now I have a question what will be the best way to create business objects? If I will create product which will contains ProductTranslation object, the binding and working in UI will be complex, if only the localized object I will have to create a different objects for CMS
Thanks a lot!
views:
195answers:
1
+1
A:
Difficult to answer, since this depends on your exact needs. What we have in one place is this (based on the DB model described in the other question):
- the business objects are modeled after the database, meaning we have a class Product which has a collection of ProductTranslation objects
- in Product class we have properties for the multilingual-data, e.g. Description
- the getter of these properties look up the correct translation object (based on the current language) and return the corresponding value
a very simple example (showing only the relevant parts):
class ProductTranslation
{
public string Description;
}
public class Product
{
private List<ProductTranslation> _translations;
private ProductTranslation GetTranslation(string language)
{
// return translation for specified language
// or return translation for default language
}
public string Description
{
get
{
return GetTranslation(GetCurrentLanguage()).Description;
}
}
}
We chose this approach for an ASP.NET web application. The CurrentLanguage may be different for each user (users can select their preferred language for the UI and the data). This approach allows us to cache data globally for all users.
Depending on your needs, this approach might not be the best. E.g. it might be better to model the Product and ProductTranslation tables as one business object (Product) which is then loaded for a specific language (e.g. if the data is read-only and it is not required to cache it application-wide).
M4N
2009-05-30 14:32:17
Thanks again Martin, helpful post
ArsenMkrt
2009-05-30 15:31:32