SIGN UP MEMBER LOGIN:    
ARTICLE

Change Locale of SharePoint Site - Code behind

Posted by Bhushan Gawale Articles | SharePoint February 28, 2011
How to change Locale of SharePoint Site - Code behind.
Reader Level:

While working with SharePoint sites, we can change the regional settings of the site by using user interface and that's easily done.

You can do it like:

Click on Site Actions > Site Settings > Click on Regional Settings link under Site Administration

and this is the small code which you as a developer can use

I have used hard coding here to Initialize Culture Info object but you can do customizations according to your need.

I hope this helps some one.

namespace ChangeCulture

{

  class Program

  {

    static void Main(string[] args)

    {

      using (SPSite site = new SPSite("http://yoursite"))

      {

        try

        {

          using (SPWeb web = site.RootWeb)

          {

            ChangeCulture(web);

          }

         }

        catch (Exception ex)

        {

         Console.WriteLine(string.Format("{0}:{1}","Error: ", ex.Message));

        }

       }

      }

    private static void ChangeCulture(SPWeb web)

    {

      if (web != null)

      {

        web.AllowUnsafeUpdates = true;

        //Initialize CultureInfo

        CultureInfo ci = new CultureInfo("en-US");

        if (ci != null)

        {

           Console.WriteLine(string.Format("{0}{1}""Processing ", web.Name));

          web.Locale = ci;

          web.Update();

        }

         web.AllowUnsafeUpdates = false;

       }

       if (web != null)

       {

         foreach (SPWeb _web in web.Webs)

         {

           ChangeCulture(_web);

         }

       }

     }

    }

}

Login to add your contents and source code to this article
share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Become a Sponsor