views:

118

answers:

1

I want to get a list of timezones, so that i can populate the dropdown list. In .NET 3.5, we have TimeZoneInfo namespace, here is the code:

ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();
foreach (TimeZoneInfo timeZone in timeZones)
    string name = timeZone.DisplayName

However, "DisplayName" is in English. How can I pass the cultureInfo so that it can return other languages? I tried setting the Thread.CurrentCulture and CurrentUICulture, it didn't work. Am I missing something?

+1  A: 

It depends on the OS. Straight from MSDN blog:

On down-level platforms such as Windows XP and Windows Server 2003, only the Display, Std, and Dlt keys exist. The Display, Std, and Dlt key values are localized only in the default language of the operating system. Because of the Windows time zone registry architecture, CurrentUICulture settings do not impact the values of these TimeZoneInfo properties.

It seems that on win xp and server 2003, you're out of luck.

On vista, win7 and server 2008, you should be able to get an other language by changing regional settings. Multilingual User Interface (MUI) support seems to be the key:

MUI-enabled operating systems such as Windows Vista contain MUI_Display, MUI_Std, and MUI_Dlt keys, which are indirectly controlled by the operating systems regional settings

EDIT: I did a quick test on win7, setting the CurrentUICulture does not change the output language of those keys. It seems changing the regional settings is the only way. This does require you to close your session to take effect though.

marapet