Try Now
More in this section

Forums / Developing with Sitefinity / proper way to retrieve laguage / culture within custom widget

proper way to retrieve laguage / culture within custom widget

2 posts, 0 answered
  1. Sheldon
    Sheldon avatar
    11 posts
    02 Oct 2013
    11 Mar 2014
    Link to this post

    This may be an easy question, but so far I haven't come up with "the best" strategy. (I am still pretty new to Sitefinity)

    I have built a custom widget that displays product catalogue data from various countries.   The database that drives these various catalogues includes a language field that consists of standard language codes ... (EN, FR, ES,.. etc)
    On pages that this custom widget is used on, we plan to drop the out--of-the box language selection widget that comes with sitefintiy.   

    Within the custom widget I want to read the language settings of the page and include that in the WHERE clause that is issue to the database when retrieving product information.   

     Should I just be using System.Globalization and System.Threading to retrieve the current culture information?  Or is there an alternative method that somehow queries the laguage selection widget to retrieve this info.

     Any recommendations?

  2. Arno
    Arno avatar
    249 posts
    08 Sep 2010
    12 Mar 2014 in reply to Sheldon
    Link to this post

    Sitefinity should set the culture of the current thread. I use Threading.Thread.CurrentThread.CurrentUICulture and that works quite well. I think I ran in one situation once where I needed an alternative approach, but I can't recall what it was.

2 posts, 0 answered