Yes,
This is something that we need to deal with.
First I would create a well known document with language settings:
public class LanguageSettings
{
public string Id { get { return "WellknownDocuments/LanguageSettings"; } }
public string DefaultLanguage { get; set; }
public List<string> SupportedLanguages { get; set; }
public static LanguageSettings Instance { get; set; }
}
To show products to the user you can use a view model that projects localized properties in the current language.
It would be great to have a mapper or something that simplifies things like this:
public class ProductViewModel
{
public string Id { get; set; }
public decimal UnitPrice { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public ProductViewModel(){}
public ProductViewModel(Product product, string languageCode)
{
this.Id = product.Id;
this.UnitPrice = product.UnitPrice;
Product.Localized lp = null;
if (product.LocalizedProperties != null)
{
if (!product.LocalizedProperties.TryGetValue(languageCode, out lp))
{
if (!product.LocalizedProperties.TryGetValue(LanguageSettings.Instance.DefaultLanguage, out lp))
{
lp = product.LocalizedProperties.Select(kv => kv.Value).FirstOrDefault();
}
}
}
if (lp != null)
{
this.Name = lp.Name;
this.Description = lp.Description;
}
}
}
There is a problem with searching, though. If there is no translation you will not find anything. But searching for the default language would probably return no results either.
Perhaps you could make sure that every localizable entity have a translation in every supported language.