I already blogged about Automatically applying theme to a SharePoint Foundation 2010 subsite but it seems language settings are not propagated to the subsite either. Imagine this scenario:

A site collection http://intranet has been created with the default English language template. Administrator enabled Italian and French languages to be used on this site collection. Once user selects a language, (s)he should be able to use the same language throughout the entire site collection.

However, this will not be applied automatically. When someone creates a subsite, multi-language features will not be enabled by default. This can be easily solved by a simple feature. You can download the feature here. Install, deploy and activate it for your site collection and you are ready to go!

Please note: This feature is not a SharePoint Sandboxed solution as certain SPWeb properties related to language settings are not available in sandboxed solutions.

Code sample, full source available:

if (properties.Web.Site.RootWeb.IsMultilingual) // will be applied if RootWeb of SiteCollection is also Multilingual
{
    using (SPWeb web = properties.Web)
    {
        web.IsMultilingual = true;

        SPLanguageCollection installed = SPRegionalSettings.GlobalInstalledLanguages;
        IEnumerable<CultureInfo> supported = web.SupportedUICultures;

        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();
    }
}

Leave a Reply