I want to find a way to force CSOM to always return values in en-us (1033 locale). For instance, when I'm trying to get ContentType Name using ContentType.get_name() I end up getting different results depending on the current UI language. This is very inconsistent and hard to work with. For instance, when the current lcid is set to 1049 ContentType Name for Folders is returned as 'Папка'. When it is set to 1033 - 'Folder' is returned. I want to find a way to explicitly retrieve items in en-us context, but can't find a way to do so.
Here is a code snippet, I'm using:
function retrieveListItems() {
var clientContext = new SP.ClientContext("/");
var oList = clientContext.get_web().get_lists().getByTitle('EnUsDocs');
var camlQuery = SP.CamlQuery.createAllItemsQuery();// new SP.CamlQuery();
SP.CamlQuery.createAllItemsQuery();
this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem, 'Include(ContentType, ContentTypeId, Title, Editor, Author, ID)');
clientContext.executeQueryAsync(Function.createDelegate(this, onQuerySucceeded), Function.createDelegate(this, onQueryFailed));}
function onQuerySucceeded(sender, args) {
var listItemInfo = '';
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
var ContentType = oListItem.get_contentType();
var name = ContentType.get_name();
console.log(name);
}
//Outputs 'Folder' or 'Папка' Depending on the lcid parameter in cookies";
console.log(listItemInfo);
}
function onQueryFailed(sender, args) {
console.warn('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
I have checked the difference in the Requests between UI languages with Fiddler. The only difference is in the cookie key 'lcid'. I was thinking about changing this cookie key from JavaScript, but this method will change my UI. Also, it seems a bit dirty.