How to Set the Active Language of a Catalog
The active language of a catalog is the language in which the multilingual data of the catalog appears. You specify the active language when you get a catalog to display. The specified language must be a language on the catalog.
You can also set the active language explicitly.
To set the active language of a catalog
Use the GetCatalog method on the CatalogContext object to get a catalog in the language specified by the language parameter. The specified language must be a language on the catalog.
Note
If you use the GetCatalog method to get the catalog, the catalog is returned in the default language for the Catalog System.
- or -
Use the ActiveLanguage property on the ProductCatalog object to get and set the active language.
Note
If you use this property, you must first save all changes to the catalog. The system then re-fetches the multilingual data of the catalog.
Example
The following example illustrates how to set the active language for a catalog. It gets the catalog "Adventure Works Catalog" with French as the language in which to display the multilingual data. It writes the active language to the console. It then uses the ActiveLanguage property to set the active language to English, and writes the new active language to the console.
public static void SetActiveLanguage(CatalogContext context)
{
// Get the "Adventure Works Catalog" with French as the active language.
ProductCatalog catalog = context.GetCatalog("Adventure Works Catalog", "fr-FR");
// Display the active language on the console.
Console.WriteLine(catalog.ActiveLanguage);
// Set the active language to English.
catalog.ActiveLanguage = "en-EN";
// Display the active language.
Console.WriteLine(catalog.ActiveLanguage);
}