Determine which languages are activated on a SharePoint site with REST API

If you develop mobile applications which need to be multilingual, it will happen sooner or later that you wanted to know which languages are activated on your SharePoint sites.

To retrieve information about your SharePoint sites, your first instinct will be to use the REST API. To achieve this goal you typically call URLs such as :

https://contoso.sharepoint.com/_api/Web
https://contoso.sharepoint.com/sites/HR/_api/Web

By default when you call those URLs, not all properties available for the site are returned in the server response. Only a subset (called the default scalar property set) is included in the response as you can see in the sample below :

{
    AllowRssFeeds = 1;
    AlternateCssUrl = "";
    AppInstanceId = "00000000-0000-0000-0000-000000000000";
    Configuration = 0;
    Created = "2015-06-05T15:12:37.89";
    CustomMasterUrl = "/_catalogs/masterpage/seattle.master";
    Description = "A new description for the Contoso Team Site";
    DocumentLibraryCalloutOfficeWebAppPreviewersDisabled = 0;
    EnableMinimalDownload = 1;
    Id = "7e75f9bc-db75-4425-b934-86bdf913f9c5";
    IsMultilingual = 1;
    Language = 1033;
    LastItemModifiedDate = "2015-08-05T17:11:31Z";
    MasterUrl = "/_catalogs/masterpage/seattle.master";
    OverwriteTranslationsOnChange = 0;
    QuickLaunchEnabled = 1;
    RecycleBinEnabled = 1;
    ServerRelativeUrl = "/";
    SiteLogoUrl = "<null>";
    SyndicationEnabled = 1;
    Title = "Contoso Team Site";
    TreeViewEnabled = 0;
    UIVersion = 15;
    UIVersionConfigurationEnabled = 0;
    Url = "https://contoso.sharepoint.com";
    WebTemplate = STS;
    "odata.editLink" = Web;
    "odata.id" = "https://contoso.sharepoint.com/_api/Web";
    "odata.metadata" = "https://contoso.sharepoint.com/_api/$metadata#SP.ApiData.Webs/@Element";
    "odata.type" = "SP.Web";
}

As you can see in the default scalar property set, we are able to know if the current site is multilingual or not (IsMultilingual = 1), but we don’t know which languages have been activated.

To retrieve the value we want, we need to modify our call to the REST API so that we have to include additional parameters in the querystring to specify which properties must be included in the server response.

https://contoso.sharepoint.com/_api/Web?$select=Title,Url,IsMultilingual,SupportedUILanguageIds

When we execute that request, the server return the following response, and we now are able to know which languages (SupportedUILanguageIds) are used by our SharePoint site.

{
    IsMultilingual = 1;
    SupportedUILanguageIds =     (
        1033,
        1036
    );
    Title = "Contoso Team Site";
    Url = "https://contoso.sharepoint.com";
    "odata.editLink" = Web;
    "odata.id" = "https://contoso.sharepoint.com/_api/Web";
    "odata.metadata" = "https://contoso.sharepoint.com/_api/$metadata#SP.ApiData.Webs/@Element&$select=Title,Url,IsMultilingual,SupportedUILanguageIds";
    "odata.type" = "SP.Web";
}

Note that although it’s very useful to be able to select which properties will be included in the server response, if you want to include all the default properties plus a new one (SupportedUILanguageIds in our case), you have to put the entire list in the querystring.

Many types in SharePoint REST API doesn’t include all available properties in their default scalar property set. If you need to know which properties are included and which are not, you can refer to the documentation (e.g. https://msdn.microsoft.com/en-us/library/dd928431%28v=office.12%29.aspx).

Advertisements

One thought on “Determine which languages are activated on a SharePoint site with REST API

  1. Marcia

    Skype has launched its internet-centered consumer beta
    towards the entire world, after establishing it broadly within the United states and U.K.

    before this four weeks. Skype for Internet also now supports Linux
    and Chromebook for instant online messaging conversation (no
    voice and video yet, all those call for a connect-in installment).

    The expansion of the beta brings help for a longer
    listing of spoken languages to assist reinforce that global usability

    Like

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s