SharePoint online: How to get alternate languages from language settings using Rest API

In this post we will discuss how we can retrieve alternative languages using Rest API in SharePoint Online. You can see the alternative language from Site settings -> then Language Settings which is under "Site Administration" section. In one of the post I have already explained how to retrieve using JavaScript client object model.

https://www.enjoysharepoint.com/wp-content/uploads/2018/07/get-alternative-languages-using-javascript-object-model-sharepoint-2013.png

Below is the full code which I have put in a script editor web part inside a web part page. Then click on Edit Snippet and put the below code inside the script editor web part. You can use the code according to your requirement.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>

<script>

$(function(){

    $("#btnClick").click(function(){

        var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/supportedUILanguageIds";

        $.ajax({

            url: requestUri,

            type: "GET",

            headers: {

                "accept":"application/json;odata=verbose",

                "content-type": "application/json;odata=verbose",

                "X-RequestDigest":$("#_REQUESTDIGEST").val()

            },

            success: onSuccess,

            error: onError

        });

        function onSuccess(data) {

            var value = data.d.SupportedUILanguageIds.results;

            alert(value);

            for (var i=0; i<value.length; i++) {

                alert(value[i]);       

            }

        }

        function onError(error) {

            alert('Error');

        }

    });

});

</script>

<input type="button" id="btnClick" value="Get AlternateLanguages"/>

https://www.enjoysharepoint.com/wp-content/uploads/2018/07/sharepoint-online-get-alternate-languages-javascript-object-model.png

Hope this will be helpful.