0

Can anyone help me with getting data from sharepoint in foreign language ? Imagine, that I've alredy successfully loaded list by title like this:

enter image description here

//listTitle = "Contacten" in Dutch
var SpList = SpContext.Web.Lists.GetByTitle(listTitle);
//...all needed loading here

and after that I start using this SpList and got a problem - SpList.Title == 'Contacts' in English.

enter image description here

And because of that I can't execute any Soap query.

Error: Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.

So my question is - Can I configure language settings for SP.ClientContext or Web or List ?

For example in code below I try to find out is the specified list exists or not. But titles are in different languages.

public sealed class ListsStore : IDisposable
{
    private SP.ClientContext _clientContext;
    private HashSet<string> _listTitles;

    public ListsStore(SP.ClientContext context)
    {
        _clientContext = context;
    }

    public bool IsListsExists(string title)
    {
        if (_listTitles == null)
        {
            SP.ListCollection lists = _clientContext.Web.Lists;
            _clientContext.Load(lists);
            _clientContext.ExecuteQuery();
            _listTitles = new HashSet<string>((lists as IEnumerable<SP.List>).Select(list => list.Title));
        }

        return _listTitles.Contains(title);
    }

    public void Dispose()
    {
        if (_clientContext != null)
        {
            _clientContext.Dispose();
            _clientContext = null;
        }
    }
}
  • Just confirming whether you have list named Contacts or Contacten in site?@isxaker – Debugger Jul 12 '17 at 15:17
1

Two me there are two questions:

  1. How to use SPList.GetByTitle usign multiple languages for the title argument? In SP 2010 and below, if you are using server-side localization using the resx resource files, you can use this example. If you are using the TitleResource property, which is a bit more modern (SP 2013+), I don't think it is possible to use the SPList.GetByTitle method in multiple languages. You would have to use the title in the SPList.Title property.

  2. How to configure multiple languages for SPList and SPWeb? Depends on the version of SharePoint. In SP2013, you would use SPWeb.TitleResource and SPList.TitleResource to store the various translations for your web and list titles. Use SPUserResource.SetValueForUICulture to set the various translations and SPUserResource.GetValueForUICulture method to get the values. In SP 2010, and older, you would use localized file on the server. See this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.