1

I want to get the current site language as I am implementing a custom module that will depend on web language. I am new to SharePoint and the company is using multi language site or site collection.

Aakash Maurya
  • 8,481
  • 4
  • 42
  • 74
Marc
  • 35
  • 1
  • 4

3 Answers3

1

There are many ways to retrieve site's language. Using javascript:

//Current Language
console.log(_spPageContextInfo.currentCultureName);
console.log(_spPageContextInfo.currentLanguage);
console.log(_spPageContextInfo.webLanguage);
console.log(SP.Res.lcid);

var currentLocale = "<%= SPContext.Current.Web.Language %>";
var globalLocale = "<%= SPContext.Current.Web.Language %>";
document.getElementsByTagName('html')[0].getAttribute('lang');
Aveenav
  • 4,199
  • 1
  • 14
  • 13
  • Can you explain to me what is the SP.Res – Marc May 13 '16 at 15:47
  • It's equivalent to .resx file but in client side. Open you fav console editor (Firebug, IE tools, chrome ) and type SP.Res. you'll see all the available properties and values – Aveenav May 13 '16 at 15:53
0

You can try below code:

SPContext.Current.RegionalSettings.LocaleId - Gets the regional settings object of the current HTTP context in Microsoft SharePoint Foundation.

Also you could load language from current web

SPContext.Current.Web.Language - Gets the locale identifier (LCID) for the default language of the website.

Reference: https://social.technet.microsoft.com/Forums/en-US/e12a6797-e6b2-44c8-840c-1c09623b7a84/how-to-get-the-language-of-current-sharepoint-portal?forum=sharepointgeneralprevious

SPWeb.Language property

To Use Java Script:

You have two easy ways to get the LCID in SP JavaScript

  1. var lcid =_spPageContextInfo.currentLanguage;
  2. var lcid = SP.Res.lcid;

Get the current UI language with ECMAScript

Waqas Sarwar MVP
  • 57,008
  • 17
  • 43
  • 79
0

You can use JavaScript, there's an object available for you called: _spPageContextInfo, and then you can access currentLanguage, like:

_spPageContextInfo.currentLanguage

It will give you the language ID, in English it's 1033. You have to know ID for each language you want and that's it.

Mohamed Derhalli
  • 2,622
  • 11
  • 18