none
How to get the Language of current SharePoint Portal RRS feed

  • Question

  • Hi all,

    I need to get the langauage of the SharePoint Portal that the user is currently using. How could I get it and whcih object should be used..? and in what tpe it returns the values i.e. en-us or english..

    Thanks,

     


    K.V.N.PAVAN
    Thursday, August 25, 2011 10:22 AM

Answers

  • You should use

    SPContext.Current.RegionalSettings.LocaleId - Gets the regional settings object of the current HTTP context in Microsoft SharePoint Foundation.

    Also you could load language from current web

    SPContext.Current.Web.Language - Gets the locale identifier (LCID) for the default language of the website.

    Both properties returns a 32-bit unsigned integer that indicates the LCID for the language. Then you could use CultureInfo class to get more information.

    CultureInfo defaultCulture = new CultureInfo(lcid);

    More info here http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.language.aspx


    Senior Software Developer - Virtosoftware - Premium Web Parts for Microsoft SharePoint 2007 & 2010
    • Marked as answer by Pa1 Kumar Thursday, August 25, 2011 11:25 AM
    Thursday, August 25, 2011 11:12 AM

All replies

  • You can see the language settings in the site settings menu. You can find it under Site Administration.
    Check out my blog at www.jasperoosterveld.com. I post articles about OOTB SharePoint, Office 365, InfoPath, SharePoint Designer and the iPad.
    Thursday, August 25, 2011 10:36 AM
  • You should use

    SPContext.Current.RegionalSettings.LocaleId - Gets the regional settings object of the current HTTP context in Microsoft SharePoint Foundation.

    Also you could load language from current web

    SPContext.Current.Web.Language - Gets the locale identifier (LCID) for the default language of the website.

    Both properties returns a 32-bit unsigned integer that indicates the LCID for the language. Then you could use CultureInfo class to get more information.

    CultureInfo defaultCulture = new CultureInfo(lcid);

    More info here http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.language.aspx


    Senior Software Developer - Virtosoftware - Premium Web Parts for Microsoft SharePoint 2007 & 2010
    • Marked as answer by Pa1 Kumar Thursday, August 25, 2011 11:25 AM
    Thursday, August 25, 2011 11:12 AM
  • RegionalSettings doesn't exist in SPContext.

    SPContext.Current.Web.Languag returns the default language of current site. Since SharePoint sites support multiple langusgaes, default language may differ with the language viewed.


    • Proposed as answer by hflikawhfiuahi Wednesday, March 15, 2017 6:19 AM
    Wednesday, March 15, 2017 6:19 AM