Language Settings

Language Settings

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Configuration.Settings
  • Sitecore.Context
  • Sitecore.Data.Database

Language Settings C# Web Control Code

Sitecore.Data.Items.Item item = this.GetItem();
if (item == null) return;

string clientLanguage = Sitecore.Configuration.Settings.ClientLanguage;
string defaultLanguage = Sitecore.Configuration.Settings.DefaultLanguage;
string checkSecurityOnLanguages = Sitecore.Configuration.Settings.CheckSecurityOnLanguages.ToString();
string autoRemoveItemData = Sitecore.Configuration.Settings.Languages.AutoRemoveItemData.ToString();
string autoRenameItemData = Sitecore.Configuration.Settings.Languages.AutoRenameItemData.ToString();

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.Write("C# Web Control Real-time Output");
output.RenderEndTag(); //Div

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
//using : for colon and ? for question mark and   for space
output.Write("{0}: {1}", "Item", item.DisplayName);
output.RenderEndTag(); //P

output.Write("{0}&#58;&#160;{1}", "Client Language", "<b>" + clientLanguage + "</b></br>");
output.Write("{0}&#58;&#160;{1}", "Default Language", "<b>" + defaultLanguage + "</b></br>");
output.Write("{0}&#63;&#160;{1}", "Check Security On Languages", "<b>" + checkSecurityOnLanguages + "</b></br>");
output.Write("{0}&#63;&#160;{1}", "Automatically Remove Item Data", "<b>" + autoRemoveItemData + "</b></br>");
output.Write("{0}&#63;&#160;{1}", "Automatically Rename Item Data", "<b>" + autoRenameItemData + "</b>");

output.RenderEndTag(); //Div


Language Settings C# Web Control Output

Client Language: en
Default Language: en
Check Security On Languages? True
Automatically Remove Item Data? True
Automatically Rename Item Data? True