proper way to retrieve laguage / culture within custom widge

Posted by Community Admin on 04-Aug-2018 20:15

proper way to retrieve laguage / culture within custom widget

All Replies

Posted by Community Admin on 11-Mar-2014 00:00

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?

Posted by Community Admin on 12-Mar-2014 00:00

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.

This thread is closed