Is it possible in SharePoint 2013 to create site columns, content types, lists, libraries, ... in different languages (so, with different display names) by CSOM (client server object model) or a webservice?
3 Answers
This is an old post. Just leaving this here for anyone to find. Extension method tricks SharePoint to believe you are accessing in the specified language. Tested and working in SP2013 and SPO. Requirement: Language must be installed in Farm and activated in SiteCollection
public static void ExecuteLocalizedQuery(this ClientRuntimeContext ctx, CultureInfo cltInfo)
{
var back = ctx.PendingRequest.RequestExecutor.WebRequest.Headers["Accept-Language"];
ctx.PendingRequest.RequestExecutor.WebRequest.Headers["Accept-Language"] = cltInfo.Name;
ctx.ExecuteQuery();
ctx.PendingRequest.RequestExecutor.WebRequest.Headers["Accept-Language"] = back;
}
You may then go and apply any elements you can think of e.g. Content Type name:
ct.Name = englishname;
ct.Update(true);
ct.Context.ExecuteLocalizedQuery(1033);
Tashunko's answer will only modify the pending request. If you want to set the language for all request for the lifetime of the ClientContext object you can set the Accept-Language header from an EventHandler.
public ClientContext Create(Uri webUri)
{
var clientContext = new ClientContext(webUri);
clientContext.ExecutingWebRequest += new EventHandler<WebRequestEventArgs>((s, e) => OnExecutingWebRequest(s, e);
return clientContext;
}
private void OnExecutingWebRequest(object sender, WebRequestEventArgs e)
{
e.WebRequestExecutor.RequestHeaders[HttpRequestHeader.AcceptLanguage] = Thread.CurrentThread.CurrentUICulture.Name;
}
Yes it is possible.
Look here CSOM vs JSOM vs SSOM vs REST and here Choose the right API set in SharePoint 2013.