I’m currently designing a e-commerce solution. One of the primary requirements is for the store to support localized item details. The same store must be able to support multiple languages via the user’s language selection and/or browser preference.
I have two tables:
Item (id, sku, price, …)
ItemDetails (item_id, language, title, …)
For each Item, there will be multiple rows corresponding to the item, where the (item_id,language) pair will be unique.
I would like to model this as:
class Item
{
public string sku;
public double price;
public ItemDetails Details;
}
Based on the user’s session, I would like the items returned to have the Details object corresponds to the user’s selected language (from their session).
What are some approaches for representing this?
I’m working on a similar globalization, where there is much dynamic content stored in the database. The approach I’m taking to allow for multilingual dynamic data is like this:
Where @CultureCode is a parameter passed in from your application, and a Culture table contains a list of your different languages/cultures for reference or to specify fallback language dependencies.
You can expand this for multiple fallback languages if need be. It’s a bit of a hit on the database compared to a single language implementation, but will accommodate the dynamic nature of your data, and that’s just a cost of a multilingual dynamic site. Caching will be your friend if you have data that doesn’t change too rapidly to help reduce the added database load.