Thursday, 4 February 2016

SharePoint: The language is not supported on the server

My current requires nested sub webs to have a specific language/regional setting. The problem arose when I started changing the Regional Settings from English (US) to English (Australia).

$web = Get-SPWeb $siteCollectionUrl
$culture=[System.Globalization.CultureInfo]::CreateSpecificCulture("en-AU")
$web.Locale=$culture
$web.Update()

OR

      myWeb.Locale = System.Globalization.CultureInfo.CreateSpecificCulture("en-AU");

However, this started to cause problems when users started to create their nested webs.

I was using the following C# code to create the webs:

var newWeb = web.Webs.Add("Name","Title", "My Web", site.RootWeb.RegionalSettings.LocaleId, webTemplate, false, false);

The locale I was referencing (3081) is not installed on the server - only the default 1033. It was trying to create new the site using the regional settings I had set previously. This was a bit of a problem: I need to create  the site and ensure the correct regional settings.

The 'hack' solution was to force the subsite to use 1033 and then change the locale afterwards.

var newWeb = web.Webs.Add("Name","Title", "My Web", 1033, webTemplate, false, false);
newWeb.Locale = System.Globalization.CultureInfo.CreateSpecificCulture("en-AU");

No comments:

Post a comment