Enabling Support for Alternate Languages in SharePoint 2010


In this article we will be seeing how to enable support for alternate languages in SharePoint 2010.

The installed languages in the SharePoint server can be supported by the site which is specified by the owner of the site, so that users who navigate to the site can then change the display language of the user interface to any of these alternate languages.

For more information on Alternate Languages refer http://www.c-sharpcorner.com/UploadFile/anavijai/7304/ (Copy the link and paste).

I have installed the Hindi language pack in my SharePoint 2010 server, in this I am going to enable support for Hindi language (Alternate language).

Go to Site Actions => Site Settings => Site Administration => Language Settings.

ShareLang1.gif

Check the Hindi language in the Alternate language's section.

ShareLang2.gif

Click on Ok.

Now the users have the ability to change the language of the User interface for a website to Hindi language as shown in the following.

ShareLang3.gif

The same thing can be achieved using SharePoint 2010 object model.

Steps Involved:

  • Open Visual Studio 2010.
  • Go to File => New => Project.
  • Select Console Application template from the installed templates.
  • Enter the Name and click Ok.
  • Add the following assembly.

    • Microsoft.SharePoint.dll
     
  • Add the following namespace.

    • Using Microsoft. SharePoint ;
    • Using System.Globalization;
     
  • Program.cs looks like the following.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint;
    using System.Xml;
    using System.Globalization;

    namespace EnableAlternateLanguage
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (SPSite site = new SPSite("http://serverName:22222/sites/LanguageTest/"))
                {
                    using (SPWeb web = site.RootWeb)
                    {
                        web.IsMultilingual = true;
                        SPLanguageCollection installedLanguages = web.RegionalSettings.InstalledLanguages;
                        IEnumerable<CultureInfo> supportedLanguages = web.SupportedUICultures;
                        foreach (SPLanguage language in installedLanguages)
                        {
                            CultureInfo culture = new CultureInfo(language.LCID);
                            if (!supportedLanguages.Contains(culture))
                            {
                                web.AddSupportedUICulture(culture);
                            }
                        }
                        web.Update();
                        Console.ReadLine();
                    }               
                }            
            }
        }
    }


    • Build the solution.
    • Hit F5.
    • All the alternate languages will be supported by the website.

Enable Alternate Languages using powershell:

  • Go to Start => All Programs => Microsoft SharePoint 2010 products => SharePoint 2010 Management Shell.
  • Run as an administrator.
  • Run the following script.

    $site= Get-SPSite "http://servername:22222/sites/LanguageTest/"
    $web=$site.Rootweb
    $web.Ismultilingual=$true
    $installedLanguages=$web.RegionalSettings.InstalledLanguages
    $supportedLanguages = $web.SupportedUICultures
    foreach ($language in $installedLanguages)
    {
    $culture = New-Object System.Globalization.CultureInfo($language.LCID)
    if (($supportedLanguages -contains($culture)) -eq $false )
    {
    $web.AddSupportedUICulture($culture)
    }
    $web.Update()
    }  
     

Up Next
    Ebook Download
    View all
    Learn
    View all