We take pride in your success. We let our positivity drive us, day in and out. Talk to us at Mindfire to know us more.

Software Technology Tips

SharePoint provides options to create sites with different types of locales available out of the box. Suppose we have a SharePoint site built using the English locale and we want to change the existing site to some other locale then this can be achieved using the following piece of code. Changing the locale of the site helps display the date and number formats with their respective decimal and group separators. The example below shows changing an existing SharePoint site into Italian locale.
CultureInfo cultInfo = new CultureInfo("it-IT", false);
NumberFormatInfo noFormatInfo = cultInfo.NumberFormat;
 
foreach (CultureInfo cInfo in CultureInfo.GetCultures(CultureTypes.AllCultures))
{
    if (!cInfo.IsNeutralCulture)
    {
        DateTimeFormatInfo dtformat = cInfo.DateTimeFormat;
        NumberFormatInfo nformat = cInfo.NumberFormat;
 
        if (cInfo.LCID == cultInfo.LCID &&
           dtformat.ShortDatePattern == "dd/MM/yyyy" &&
           nformat.NumberDecimalSeparator == noFormatInfo.NumberDecimalSeparator&&
           nformat.NumberGroupSeparator == noFormatInfo.NumberGroupSeparator)
        {
            using (SPSite site = new SPSite("http://sharepointSite"))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    web.AllowUnsafeUpdates = true;
                    web.Locale = cInfo;
                    web.Update();
                }
            }
        }
    }
}


Related Tags:

SharePoint

Author: Saroj Dash

top

Related Pages

  • SharePoint Development India
  • SahrePoint Development Projects

SharePoint

Let us Connect!

privacy

copyright (c) Mindfire Solutions 2007-2012. Login