Geeks With Blogs
A Curious Mind #tastic

I am working on domain where I need to support the ability to translate content. Such as a product description. I am imagining that the domain model might look something like:

product.Description = "Widget";
product.Translation[Language.English].Description = "Tegdiw";

or

product.Description = "widget";
product.Description[Language.English] = "tegdiw";

or

IProduct product = repository.Get(1, English);
product.Description = "wow";
IProduct productZh = repository.Get(1, Chinese);
productZh.Description = "waw";

Of the three I have presented here, I think I like number one the best. I would say that I like it the most because I have done this model before and it seemed to work well, I am just wondering how much I really care that it forces me to have 2 tables per entity that I want translations for (Product and ProductTranslations). Really that's not that bad I guess. Anyways, I wanted to put my thoughts out there to see if anyone else had some better ideas. :)

Posted on Thursday, August 14, 2008 6:37 PM | Back to top


Comments on this post: A multi-lingual domain

# re: A multi-lingual domain
Requesting Gravatar...
Try this approach:
http://www.ayende.com/Blog/archive/2006/12/26/7001.aspx
Left by Ayende Rahien on Aug 15, 2008 9:17 AM

# re: A multi-lingual domain
Requesting Gravatar...
I think you could have two tables to support all of your entities, String(Id, Value) and Translation(Id, StringId, LCID, Value).

If you are using NHibernate I recall Oren had some posts about transparently retrieving the correctly translated string based on the Thread.CurrentCulture. e.g. NHibernate would retrieve product.Description by filtering the Translation table for the proper value.
Left by Bill Pierce on Aug 15, 2008 9:59 AM

# re: A multi-lingual domain
Requesting Gravatar...
Have to say I third Oren's solution.
Left by Robz on Aug 19, 2008 7:41 PM

# re: A multi-lingual domain
Requesting Gravatar...
My problem with the oren solution is that I have some 30 translatable properties to manage, which would be a bit of a bear, and I suspect that one query with 30 sub-queries would be a bit overkill. I will detail this out a bit more in the near future.
Left by Dru on Aug 19, 2008 8:11 PM

Your comment:
 (will show your gravatar)


Copyright © Dru Sellers | Powered by: GeeksWithBlogs.net