Mercurial > babel > old > babel-test
changeset 28:11278622ede9
Import basic timezone info from CLDR (see #3). Still missing a couple other pieces in the puzzle.
author | cmlenz |
---|---|
date | Sun, 03 Jun 2007 20:25:19 +0000 |
parents | 8521326b0627 |
children | da1c9610e751 |
files | babel/core.py scripts/import_cldr.py |
diffstat | 2 files changed, 22 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/babel/core.py +++ b/babel/core.py @@ -281,6 +281,19 @@ :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="""\
--- a/scripts/import_cldr.py +++ b/scripts/import_cldr.py @@ -153,7 +153,15 @@ 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':