Retrieve alternative languages in SharePoint using JavaScript

This JSOM tutorial, will discuss, how to retrieve alternative languages from language settings in SharePoint Online using JavaScript object model (jsom). In the same way, we can get alternative languages in SharePoint 2013/2016 using JavaScript.

If you want to retrieve alternative languages in SharePoint using Rest API, then you can follow this article.

Retrieve alternative languages in SharePoint using JavaScript

You can see the alternative languages from Site settings -> language settings that are under Site Administration. It shows like below:

Retrieve alternative languages in SharePoint using JavaScript

For this particular post, I have added the below code inside a script editor web part on a SharePoint web part page.

Remember it will display like for the English language it will return 1033.

<input type="button" id="btnGetLanguages" value="Click Here"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(“#btnGetLanguages").click(function(){
GetLanguages();
});
});

var web;
function GetLanguages(){
var clientContext = new SP.ClientContext();
web=clientContext.get_web();
clientContext.load(web,"SupportedUILanguageIds");
clientContext.executeQueryAsync(Function.createDelegate(this, this.onSuccess),
Function.createDelegate(this, this.onFailure));
}

function onSuccess() {
var supportedlanguage = web.get_supportedUILanguageIds();
for (var i = 0; i < supportedlanguage.length; i++) {
var languageName = supportedlanguage[i].toString();
alert(languageName);
}
}
function onFailure(sender, args) {
alert(‘Error Occurred. ‘ + args.get_message());
}
</script>

You may like following SharePoint JSOM tutorials:

This SharePoint jsom tutorial, we learned how to get alternative languages in SharePoint Online or SharePoint 2013/2016 using the JavaScript object model (jsom).

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

  • Hi Sir, I created language link English|Arabic on master page right corner of sharepoint team site. bydefaut site language is English. When user click on Arabic langauge then complete site should show in Arabic language. Please help me how to complete this task.

  • >