Anyone know a source for translated Time Zone descriptions?
-
03-07-2019 - |
Question
Does anyone know of a compiled list of translations for the time zone names in Windows? I need all 75 or so of them in German, French and Spanish. Alternatively, how would I use .Net to compile such a list?
Example format: (GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague
Solution
There is a list of all the time zones in the registry at:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones
Which can be loaded using:
ArrayList zones = new ArrayList();
using( RegistryKey key = Registry.LocalMachine.OpenSubKey(
@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones" ) )
{
string[] zoneNames = key.GetSubKeyNames();
foreach( string zoneName in zoneNames )
{
using( RegistryKey subKey = key.OpenSubKey( zoneName ) )
{
TimeZoneInformation tzi = new TimeZoneInformation();
tzi.Name = zoneName;
tzi.DisplayName = (string)subKey.GetValue( "Display" );
tzi.StandardName = (string)subKey.GetValue( "Std" );
tzi.DaylightName = (string)subKey.GetValue( "Dlt" );
object value = subKey.GetValue( "Index" );
if( value != null )
{
tzi.Index = (int)value;
}
tzi.InitTzi( (byte[])subKey.GetValue( "Tzi" ) );
zones.Add( tzi );
}
}
}
Where TimeZoneInformation is just a class which stores the information for easy access.
The description you're looking for is in the Display value.
OTHER TIPS
Get the time zone database from https://iana.org/time-zones or ftp://ftp.iana.org/tz (or the many other source on the web). These will be keyed in UN ISO codes and English country/City names
And then translate them from http://www.unicode.org/cldr/
e.g.
The Microsoft Terminology Collection is available for download for non-commercial use.