This sounds like a simple thing right? Just set the Locale of the SPWeb object to the locale you are interested in. Not so fast – this does not work, it will change the Locale but not things like the calendar being used. What you have to do is to create a new instance of SPRegionalSettings and set a few properties like LocaleId, CalendarType and Time24. |
Here is a code snippet that does just this: |
CultureInfo ci = new CultureInfo(your culture); SPRegionalSettings rs = new SPRegionalSettings(web, false); rs.LocaleId = (uint)ci.LCID; rs.Time24 = rs.GetDefaultTime24((uint)ci.LCID); rs.CalendarType = (short)rs.GetDefaultCalendarType(ci.LCID); web.RegionalSettings = rs; web.Update(); |
I spent several hours trying to figure this out, so I hope this will help someone else trying to do the same. |