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.
Asked
Active
Viewed 5,944 times
3 Answers
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.
To Use Java Script:
You have two easy ways to get the LCID in SP JavaScript
var lcid =_spPageContextInfo.currentLanguage;var lcid = SP.Res.lcid;
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