65.9K
CodeProject is changing. Read more.
Home

How To Get the Current Culture in SharePoint 2013

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

May 8, 2016

CPOL
viewsIcon

10764

How to get current culture in SharePoint 2013 Online? How to get current culture using client object model C#?

Introduction

Get UICulture/Current culture in Server Object Model is very easy. In Client Object Model, it is little bit of a problem. So this document aims to overcome it.

What is UICulture/Current Culture

It is the default language of a SharePoint Site. It can be found in Site Settings --> Regional Settings

uiculture

Using the Code

In Server Object Model, it is already there. SPWeb has a property named UICulture. Unfortunately, it is missing in Client Object Model. So what to do? I wrote the following:

public string GetCultureOfTheWeb(ClientContext clientContext)
        {
            var web = clientContext.Web;
            clientContext.Load(web.RegionalSettings);
            clientContext.ExecuteQuery();
            var localId = (int) web.RegionalSettings.LocaleId;
            return new CultureInfo(localId).Name;
        }