|
/// <summary>
/// Language support for property definitions
/// </summary>
/// <param name="catalogContext"></param>
internal void AddLanguagesToPropertyDefinitions(CatalogContext
catalogContext)
{
// Add the languages to the Property definitions
catalogContext.AddLanguageToPropertyDefinitions("en-US");
catalogContext.AddLanguageToPropertyDefinitions("fr-FR");
// Get the langauges added to the Property definitions
foreach(string language in
catalogContext.GetPropertyDefinitionLanguages())
{
Console.WriteLine(language);
}
// To set the displaynames for properties
// Get the CatalogProperty object
CatalogProperty property = catalogContext.GetProperty("Name");
// For a language X, you can get/set the display name in the
// DisplayName_X property
property["DisplayName_en-US"] = "Name";
property["DisplayName_fr-FR"] = "Nom";
// Save the displaynames
property.Save();
// Get the English display names
string displayNameEn = null;
// Ensure that the property exists and it has a value
if ( property.HasProperty("DisplayName_en-US") &&
!property.IsPropertyNull("DisplayName_en-US"))
{
displayNameEn = (string)property["DisplayName_en-US"];
}
// Remove the language
catalogContext.RemoveLanguageFromPropertyDefinitions("fr-FR");
} |