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
CultureInfo.Provider.Set(newCulture);

> Back to list of examples

Updating a culture



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

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

    // Saves the modified culture to the database
    CultureInfo.Provider.Set(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
    CultureInfo.Provider.Set(culture);
}

> Back to list of examples

Assigning a culture to a site



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

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

> Back to list of examples

Removing a culture from a site



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

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

    if (cultureSite != null)
    {
        // Removes the culture from the current site
        CultureSiteInfo.Provider.Delete(cultureSite);
    }
}

> Back to list of examples

Deleting a culture



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

if (deleteCulture != null)
{
    // Deletes the culture
    CultureInfo.Provider.Delete(deleteCulture);
}

> Back to list of examples