Compartir a través de


Adding multilingual display names to property definitions

         The Commerce Server 2007 catalog system supports multilingual display names for Property definitions, catalog definitions, products, categories and variants. This post discusses multilingual display name support for property definitions.

         The following are the steps to add multilingual display names for property definitions

  1. Add the desired langauges to the property definitions
  2. Set the display names for the desired property.

While the above steps can be performed from the Catalog and Inventory Schema Manager, you can programatically achieve this as follows:

/// <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");

                 

}

Comments