Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

SPWeb.AddSupportedUICulture method

Adds culture-specific information to the list supported by the website.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
public void AddSupportedUICulture(
	CultureInfo cultureInfo
)

Parameters

cultureInfo
Type: System.Globalization.CultureInfo

The culture-specific information to add.

This method adds the information about the culture to the list in the SupportedUICultures property.

Use this method to add a language to the list of alternative languages supported by the website's multilingual user interface (UI). Any language that you add should already be installed on the server farm. A list of installed language packs is returned by the SPRegionalSettings.GlobalInstalledLanguages property.

Caution noteCaution

Some web templates do not support the multilingual UI. Before you call this method, check the value of the SupportsMultilingualUI property of the web template that was used to create the website.

The following example is a console application that enumerates the installed languages and adds any that are currently not supported to the list of supported cultures.

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("http://localhost"))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    // Be sure the web template supports MUI. Some templates do not.
                    if (site.GetWebTemplates(web.Language)[web.WebTemplate].SupportsMultilingualUI)
                    {
                        // Enable MUI.
                        web.IsMultilingual = true;

                        // Get the languages that are installed on the farm.
                        SPLanguageCollection installed = SPRegionalSettings.GlobalInstalledLanguages;

                        // Get the languages supported by this website.
                        IEnumerable<CultureInfo> supported = web.SupportedUICultures;

                        // Enable support for any installed language that is not already supported.
                        foreach (SPLanguage language in installed)
                        {
                            CultureInfo culture = new CultureInfo(language.LCID);

                            if (!supported.Contains(culture))
                            {
                                Console.WriteLine("Adding {0}", culture.Name);
                                web.AddSupportedUICulture(culture);
                            }
                        }
                        web.Update();

                    }
                }
            }
            Console.Write("\nPress ENTER to continue....");
            Console.Read();
        }
    }
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.