python-babel / babel

The official repository for Babel, the Python Internationalization Library
http://babel.pocoo.org/
BSD 3-Clause "New" or "Revised" License
1.32k stars 438 forks source link

get_global('windows_zone_mapping') is lossy #464

Open ecederstrand opened 7 years ago

ecederstrand commented 7 years ago

According to http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml, there is a one-to-many relationship from Windows timezone to 'standard' timezone name. But the importer (see https://github.com/python-babel/babel/blob/master/scripts/import_cldr.py#L234) blindly selects only the first timezone name for the map value:

>>> get_global('windows_zone_mapping')['Romance Standard Time']
'Europe/Paris'

I think get_global('windows_zone_mapping') should either return tuples with all the related timezone names:

>>> get_global('windows_zone_mapping')['Romance Standard Time']
('Europe/Paris', 'Europe/Brussels', 'Europe/Copenhagen', 'Europe/Madrid Africa/Ceuta')

or be turned around so it maps timezone name -> Windows timezone:

>>> get_global('windows_zone_mapping')['Europe/Copenhagen']
'Romance Standard Time'

I think the latter is preferable since it's a more simple data structure, and if you need the reverse mapping, it's a one-liner:

reverse_zone_map = {v: k for k, v in get_global('windows_zone_mapping').items()}
abhishekcs10 commented 7 years ago

I want to work on this issue. What is to be preferred? Returning tuple or other way around.?.

ecederstrand commented 7 years ago

If the latter is preferred, I already submitted https://github.com/python-babel/babel/pull/465