]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Import basic timezone info from CLDR (see #3). Still missing a couple other pieces...
authorChristopher Lenz <cmlenz@gmail.com>
Sun, 3 Jun 2007 20:25:19 +0000 (20:25 +0000)
committerChristopher Lenz <cmlenz@gmail.com>
Sun, 3 Jun 2007 20:25:19 +0000 (20:25 +0000)
babel/core.py
scripts/import_cldr.py

index 62642b4e45d1744e0b6e22b2c3e42e963f2e79b5..bdbef11efb28d4bffb6967e0d083965383ea9c6f 100644 (file)
@@ -281,6 +281,19 @@ class Locale(object):
         :type: `dict`
         """)
 
+    def time_zones(self):
+        return self._data['time_zones']
+    time_zones = property(time_zones, doc="""\
+        Locale display names for time zones.
+        
+        >>> Locale('en', 'US').time_zones['America/Los_Angeles']['long']['standard']
+        u'Pacific Standard Time'
+        >>> Locale('en', 'US').time_zones['Europe/Dublin']['city']
+        u'Dublin'
+        
+        :type: `dict`
+        """)
+
     def first_week_day(self):
         return self._data['week_data']['first_day']
     first_week_day = property(first_week_day, doc="""\
index 328a491c596a2f0a9b2ce8917cfb63fcd334da9e..678d672465496b4ebf659bbce9f10690960f9aff 100755 (executable)
@@ -153,7 +153,15 @@ def main():
 
         time_zones = data.setdefault('time_zones', {})
         for elem in tree.findall('//timeZoneNames/zone'):
-            time_zones[elem.tag] = unicode(elem.findtext('displayName'))
+            info = {}
+            city = elem.findtext('exemplarCity')
+            if city:
+                info['city'] = unicode(city)
+            for child in elem.findall('long/*'):
+                info.setdefault('long', {})[child.tag] = unicode(child.text)
+            for child in elem.findall('short/*'):
+                info.setdefault('short', {})[child.tag] = unicode(child.text)
+            time_zones[elem.attrib['type']] = info
 
         for calendar in tree.findall('//calendars/calendar'):
             if calendar.attrib['type'] != 'gregorian':