Localization

List of examples:

Cultures

Creating a new culture

// Creates a new culture object
CultureInfo newCulture = new CultureInfo();

// Sets the culture properties
newCulture.CultureName = "New culture";
newCulture.CultureCode = "nw-cu";
newCulture.CultureShortName = "Culture";

// Saves the new culture to the database
CultureInfoProvider.SetCultureInfo(newCulture);

> Back to list of examples

Updating a culture

// Gets the culture using the culture code
CultureInfo updateCulture = CultureInfoProvider.GetCultureInfo("nw-cu");

if (updateCulture != null)
{
	// Updates the culture properties
	updateCulture.CultureName = updateCulture.CultureName.ToLower();

	// Saves the modified culture to the database
	CultureInfoProvider.SetCultureInfo(updateCulture);
}

> Back to list of examples

Updating multiple cultures

// Prepares a where condition for loading all cultures whose code starts with 'nw'
string where = "CultureCode LIKE N'nw%'";

// Get all cultures that fulfill the condition
InfoDataSet<CultureInfo> cultures = CultureInfoProvider.GetCultures(where, null);

// Loops through individual cultures
foreach (CultureInfo culture in cultures)
{
	// Updates the culture properties
	culture.CultureName = culture.CultureName.ToUpper();

	// Saves the updated culture to the database
	CultureInfoProvider.SetCultureInfo(culture);
}

> Back to list of examples

Assigning a culture to a site

// Gets the culture using the culture code
CultureInfo culture = CultureInfoProvider.GetCultureInfo("nw-cu");

if (culture != null)
{
	// Assigns the culture to the current site
	CultureSiteInfoProvider.AddCultureToSite(culture.CultureID, SiteContext.CurrentSiteID);
}

> Back to list of examples

Removing a culture from a site

// Gets the culture using the culture code
CultureInfo removeCulture = CultureInfoProvider.GetCultureInfo("nw-cu");

if (removeCulture != null)
{
	// Gets the object representing the relationship between the culture and the current site
	CultureSiteInfo cultureSite = CultureSiteInfoProvider.GetCultureSiteInfo(removeCulture.CultureID, SiteContext.CurrentSiteID);

	if (cultureSite != null)
	{
		// Removes the culture from the current site
		CultureSiteInfoProvider.DeleteCultureSiteInfo(cultureSite);
	}
}

> Back to list of examples

Deleting a culture

// Gets the culture using the culture code
CultureInfo deleteCulture = CultureInfoProvider.GetCultureInfo("nw-cu");

if (deleteCulture != null)
{
	// Deletes the culture
	CultureInfoProvider.DeleteCultureInfo(deleteCulture);
}

> Back to list of examples


Was this page helpful?