다음을 통해 공유


AddLanguage Method

Adds the given language to the current catalog.

Namespace:  Microsoft.CommerceServer.Catalog
Assembly:  Microsoft.CommerceServer.Catalog (in Microsoft.CommerceServer.Catalog.dll)

Syntax

'Declaration
Public Sub AddLanguage ( _
    languageToAdd As String _
)
'Usage
Dim instance As ProductCatalog
Dim languageToAdd As String

instance.AddLanguage(languageToAdd)
public void AddLanguage(
    string languageToAdd
)
public:
void AddLanguage(
    String^ languageToAdd
)
public function AddLanguage(
    languageToAdd : String
)

Parameters

Exceptions

Exception Condition
ArgumentNullException

The languageToAdd is nullNothingnullptra null reference (Nothing in Visual Basic).

ValidationException

The languageToAdd is invalid.

EntityAlreadyExistsException

The languageToAdd already exists.

Remarks

This method will add the language to the current catalog. After you add a language you should call the Save method to save the changes to the catalog system. The languageToAdd should:

  • Not be nullNothingnullptra null reference (Nothing in Visual Basic) or blank.

  • Not exceed 10 characters.

  • Not contain the ,'[] characters.

  • Not already exist in the catalog.

After you add a language to the catalog a column named "DisplayName_languageToAdd" will be added to the Information dataset. You can set the display name for the catalog in this language by setting the display name on the newly added column.

Examples

internal void AddRemoveLanguages(string catalogName, string languagetoAdd, string languageToRemove)
{
  try
  {
    // Get the base catalog for the specified catalog name
    ProductCatalog productCatalog = catalogContext.GetCatalog(catalogName);
    // Call AddLanguage to add the language 
    // Call RemoveLanguage to remove the language
    productCatalog.AddLanguage(languagetoAdd);
    productCatalog.RemoveLanguage(languageToRemove);
    // Call Save to save the information to the catalog system
    productCatalog.Save();
  }
  catch (EntityAlreadyExistsException ex)
  {
    // The language already exists
    Console.WriteLine(ex.Message);
    throw;
  }
  catch (EntityDoesNotExistException ex)
  {
    // The language does not exist
    Console.WriteLine(ex.Message);
    throw;
  }
}

Permissions

See Also

Reference

ProductCatalog Class

ProductCatalog Members

Microsoft.CommerceServer.Catalog Namespace