简体   繁体   中英

Get localized list/site name from SharePoint 2013 on-premise with CSOM

I have multilingual sites on my SharePoint 2013 server (on-premise) and I would like to retrieve localized sites and lists name via the .NET Managed API (CSOM) in C#.

I tried to use the "TitleResource" property object from Web object and its GetValueForUICulture() method :

var web = spContext.Web;
var webTitleRes = web.TitleResource;
var webFrenchTitle = webTitleRes.GetValueForUICulture("fr").Value;
spContext.ExecuteQuery();

But it crashes at the last line saying that this field/property doesn't exist:

图。1

I previously tried to update the Web's "LocaleID" value as it is showed in a sample app from the Office PnP project : check here

But the server throw an Exception, saying that I don't have enough permission to do that :

图2

Well, I don't really want to update the LocaleID on the server, I just want to locally retrieve localized titles so it seems to be a completely wrong way.

How can I retrieve localized title's string from my SharePoint server? What am I missing?


Update

For reference, it seems that TitleResource and DescriptionResource attributes are only accessible from the "online" version of SharePoint, yet the MSDN doc doesn't mention anything about that, leading to a improper use of these :

图3

It may be usable in the brand new 2016 version, btw. We'll see.

the UiCulture should be a Culture object.

Try this:

blablabla.GetValueForUICulture(new CultureInfo(1036)).Value;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM