Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting system Timezones in different languages

I'm currently getting the list of all timezones like this:

var TheListOfAllTimezones = TimeZoneInfo.GetSystemTimeZones();

So for instance, the timezone in Paris has a DisplayName property of W. Europe Standard Time. Now how do I get this list in another language? For instance, for users in France, I'd like to display Heure Europe de l'Ouest.

Thanks.

enter image description here

like image 668
frenchie Avatar asked Oct 31 '12 17:10

frenchie


2 Answers

Changing the CurrentCulture doesn't work as the information comes from the registry (XP) or from the Multilingual User Interface (MUI) DLL (Vista, Windows 7).

On Vista or Windows 7, you may install other languages and change the display language (Region and Language -> Keyboards and languages -> Display language). A reboot is required. This, and only this, will actually change the language used in TimeZoneInfo.

On Windows 7, only Ultimate and Enterprise allow the installation of other languages - by means of installing Multilingual User Interface Packs.

Once you installed other languages, you should be able to find the DLLs in the system32 folder (look for tzres) and maybe export the resources with Visual Studio.

As to credible/official sources - how about an article on msdn of the BCL Team:

...the display strings are loaded either from the Multilingual User Interface (MUI) DLL, tzres.dll, or straight from the registry, when MUI support is unavailable. 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. 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.

So what did they write about CurrentUICulture ?

Because of the Windows time zone registry architecture, CurrentUICulture settings do not impact the values of these TimeZoneInfo properties.

like image 193
marapet Avatar answered Oct 20 '22 19:10

marapet


If the CurrentCulture of your thread is French ("fr-FR"), and if that language is "native" with your Windows version, then the properties StandardName and DaylightName will be in French, it seems.

Edit:

It doesn't look like changing the CurrentCulture of the thread will help. The time zones all come from the Registry (see Jim Mischel's answer for the path), and it looks like the language of the Windows installation determines the values. The IDs (which are keys in the Registry path) are always in English, while the other properties depend on the Windows language.

What is your output of the following code:

Console.WriteLine(CultureInfo.InstalledUICulture.DisplayName);

var tzi = TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time");
Console.WriteLine(tzi.Id);              // always English
Console.WriteLine(tzi.DisplayName);     // localized
Console.WriteLine(tzi.StandardName);    // localized
Console.WriteLine(tzi.DaylightName);    // localized
like image 32
Jeppe Stig Nielsen Avatar answered Oct 20 '22 21:10

Jeppe Stig Nielsen