/// <summary> /// Gets and bulk updates cultures. Called when the "Get and bulk update cultures" button is pressed. /// Expects the CreateCulture method to be run first. /// </summary> private bool GetAndBulkUpdateCultures() { // Prepare the parameters string where = "CultureCode LIKE N'MyNewCulture%'"; // Get the data DataSet cultures = CultureInfoProvider.GetCultures(where, null); if (!DataHelper.DataSourceIsEmpty(cultures)) { // Loop through the individual items foreach (DataRow cultureDr in cultures.Tables[0].Rows) { // Create object from DataRow CultureInfo modifyCulture = new CultureInfo(cultureDr); // Update the properties modifyCulture.CultureName = modifyCulture.CultureName.ToUpper(); // Update the culture CultureInfoProvider.SetCultureInfo(modifyCulture); } return(true); } return(false); }
/// <summary> /// Creates culture. Called when the "Create culture" button is pressed. /// </summary> private bool CreateCulture() { // Create new culture object CultureInfo newCulture = new CultureInfo(); // Set the properties newCulture.CultureName = "My new culture"; newCulture.CultureCode = "MyNewCulture"; newCulture.CultureShortName = "MyCultureShortName"; // Create the culture CultureInfoProvider.SetCultureInfo(newCulture); return(true); }
/// <summary> /// Update just edited culture. /// </summary> protected void UpdateCulture() { if (culture != null) { culture.CultureName = txtCultureName.Text.Trim(); culture.CultureCode = txtCultureCode.Text.Trim(); culture.CultureShortName = txtCultureShortName.Text.Trim(); culture.CultureAlias = txtCultureAlias.Text.Trim(); CultureInfoProvider.SetCultureInfo(culture); } ShowChangesSaved(); // Refresh header ScriptHelper.RefreshTabHeader(this, "general"); }
/// <summary> /// Gets and updates culture. Called when the "Get and update culture" button is pressed. /// Expects the CreateCulture method to be run first. /// </summary> private bool GetAndUpdateCulture() { // Get the culture CultureInfo updateCulture = CultureInfoProvider.GetCultureInfo("MyNewCulture"); if (updateCulture != null) { // Update the property updateCulture.CultureName = updateCulture.CultureName.ToLower(); // Update the culture CultureInfoProvider.SetCultureInfo(updateCulture); return(true); } return(false); }
/// <summary> /// Handles btnOK's OnClick event - Save culture info. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // Validate the input string result = new Validator().NotEmpty(txtCultureName.Text.Trim(), rfvCultureName.ErrorMessage).NotEmpty(txtCultureCode.Text.Trim(), rfvCultureCode.ErrorMessage).Result; if (txtCultureCode.Text.Trim().Length > 10) { result = GetString("Culture.MaxLengthError"); } // Validate the culture code try { // Check if global culture exists if (new CultureInfo(txtCultureCode.Text.Trim()) == null) { result = GetString("Culture.ErrorNoGlobalCulture"); } } catch { result = GetString("Culture.ErrorNoGlobalCulture"); } txtCultureAlias.Text = URLHelper.GetSafeUrlPart(txtCultureAlias.Text.Trim(), String.Empty); string cultureAlias = txtCultureAlias.Text.Trim(); // Check whether culture alias is unique if (!String.IsNullOrEmpty(cultureAlias)) { CMS.SiteProvider.CultureInfo ci = CultureInfoProvider.GetCultureInfoForCulture(cultureAlias); if ((ci != null) || (CMSString.Compare(cultureAlias, txtCultureCode.Text.Trim(), true) == 0)) { result = GetString("Culture.AliasNotUnique"); } } if (result == "") { // Check if culture already exists CMS.SiteProvider.CultureInfo ci = CultureInfoProvider.GetCultureInfoForCulture(txtCultureCode.Text.Trim()); if (ci == null) { // Save culture info ci = new CMS.SiteProvider.CultureInfo(); ci.CultureName = txtCultureName.Text.Trim(); ci.CultureCode = txtCultureCode.Text.Trim(); ci.CultureShortName = txtCultureShortName.Text.Trim(); ci.CultureAlias = cultureAlias; CultureInfoProvider.SetCultureInfo(ci); URLHelper.Redirect("Culture_Edit_Frameset.aspx?cultureID=" + ci.CultureID + "&saved=1"); } else { ShowError(GetString("Culture_New.CultureExists")); } } else { ShowError(result); } }