Changing the thread culture using HttpModule - not working for list forms
-
Saturday, May 05, 2012 10:26 PM
Hi
I have a requirement to implement globalization for the out of the box list forms i.e. displaying datetime, currency etc. based on culture of the region. I have referred the below articles on how SharePoint by default sets the thread culture using the SPRequest http module.
http://sadomovalex.blogspot.co.uk/2010/01/how-sharepoint-sets-currentthreadcurren.html
http://sadomovalex.blogspot.co.uk/2010/04/change-current-ui-locale-using-query.html
I have created a custom HttpModule that sets the CurrentCulture property of the thread and registered it after the SPRequest module. This works fine for layout pages and for custom webparts and I can see the datetime format being displayed on the region I choose. However this is not working for out of the box list forms i.e. AllItems.aspx, Editform.aspx, DisplayForm.aspx etc. I could see the thread culture being set in the httpmodule, but it does not have any effect on these forms.
This article http://dotnet.lv/blogs/antonsm/archive/2008/12/21/change-date-format-in-sharepoint.aspx says that list forms do not use .Net CultureInfo in these forms but instead use the LCID of SPWeb and then uses a COM library for formatting. This could well explain why changing the thread culture is not having any effect on list forms.
What is a good way to solve this? I don't have the option of creating one site per region based on locale. Also changing SPWeb.Locale is not an option.
Thanks
All Replies
-
Tuesday, May 08, 2012 10:06 AMModerator
but SharePoint 2010 already regional settings provided out of box. Could you please elaborate why do you need to customize?
for example, you can set default regional setting in web application and site settings. And user can specify their own in MySettings->my regional settings. If the user regional setting is different from default setting, the Date and Time value will change accordingly.
for currency, you can specify the currency format for currency field in field settings, it will not change with user regional setting, which is correct design.
If you want further formatting for currency or datetime field, you may consider customizing the xsltlistviewwebpart or dataformwebpart. Please refer to what follows for more:
http://msdn.microsoft.com/en-us/library/ff606773.aspx
http://msdn.microsoft.com/en-us/library/ff604024.aspx
http://support.microsoft.com/kb/2580994
http://blogs.msdn.com/b/sharepointdesigner/archive/2008/02/25/filtering-and-formatting-with-date-values.aspx?PageIndex=2
- Marked As Answer by GuYumingMicrosoft Contingent Staff, Moderator Monday, May 14, 2012 6:15 AM
-
Thursday, May 10, 2012 3:47 PM
Thanks for the reply. I know SharePoint provides out of the box regional settings, but they are not much of use in my case. I have only one common site which is used by users across the world. I have no option to create region based sites and redirect the user based on where the request is coming from. Creating the region based sites would imply duplicating the same content across all sites. To avoid this, there's only one site created using en-US culture and would like to modify just the display of date, currency etc. based on user's location. I thought changing thread culture would work, but is not woring for list forms.. Addressing a simple issue becomes massively difficult at times with SharePoint!!
-
Friday, May 11, 2012 2:24 AMModerator
You don't need to duplicate site content across multiple sites (which is called variation in SharePoint) for different regional setting. It's just that each user can have different regional setting from the default for the site.
-
Friday, May 18, 2012 2:59 PMThanks GuYuming. I wasn't aware of My Settings-->My Regional Settings. This should work.

