# HG changeset patch # User cmlenz # Date 1213619044 0 # Node ID c22f292731be9f31171387f8198128462903951b # Parent 36c243367cc9f63993239e91643ea0d12c0574a3 Update to CLDR 1.5.1, which split out the metazone mappings into a separate supplemental file. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -3,9 +3,16 @@ (?, from branches/stable/0.9.x) * Fixed invalid message extraction methods causing an UnboundLocalError. + * Extraction method specification can now use a dot instead of the colon to + separate module and function name (ticket #105). + * Fixed message catalog compilation for locales with more than two plural + forms (ticket #95). + * Fixed compilation of message catalogs for locales with more than two plural + forms where the translations were empty (ticket #97). * The stripping of the comment tags in comments is optional now and is done for each line in a comment. - * a JavaScript extractor was added. + * A JavaScript message extractor was added. + * Updated to CLDR 1.5.1. Version 0.9.2 diff --git a/babel/dates.py b/babel/dates.py --- a/babel/dates.py +++ b/babel/dates.py @@ -267,10 +267,7 @@ # Get the canonical time-zone code zone = get_global('zone_aliases').get(zone, zone) - metainfo = {} info = locale.time_zones.get(zone, {}) - if 'use_metazone' in info: - metainfo = locale.meta_zones.get(info['use_metazone'], {}) # Otherwise, if there is only one timezone for the country, return the # localized country name @@ -286,12 +283,15 @@ fallback_format = locale.zone_formats['fallback'] if 'city' in info: city_name = info['city'] - elif 'city' in metainfo: - city_name = metainfo['city'] - elif '/' in zone: - city_name = zone.split('/', 1)[1].replace('_', ' ') else: - city_name = zone.replace('_', ' ') + metazone = get_global('meta_zones').get(zone) + metazone_info = locale.meta_zones.get(metazone, {}) + if 'city' in metazone_info: + city_name = metainfo['city'] + elif '/' in zone: + city_name = zone.split('/', 1)[1].replace('_', ' ') + else: + city_name = zone.replace('_', ' ') return region_format % (fallback_format % { '0': city_name, @@ -386,7 +386,6 @@ # Get the canonical time-zone code zone = get_global('zone_aliases').get(zone, zone) - metainfo = {} info = locale.time_zones.get(zone, {}) # Try explicitly translated zone names first if width in info: @@ -397,15 +396,16 @@ if field in info[width]: return info[width][field] - if 'use_metazone' in info: - metainfo = locale.meta_zones.get(info['use_metazone'], {}) - if width in metainfo and (uncommon or metainfo.get('common')): + metazone = get_global('meta_zones').get(zone) + if metazone: + metazone_info = locale.meta_zones.get(metazone, {}) + if width in metazone_info and (uncommon or metazone_info.get('common')): if dt is None: field = 'generic' else: field = tzinfo.dst(dt) and 'daylight' or 'standard' - if field in metainfo[width]: - return metainfo[width][field] + if field in metazone_info[width]: + return metazone_info[width][field] # If we have a concrete datetime, we assume that the result can't be # independent of daylight savings time, so we return the GMT offset diff --git a/scripts/import_cldr.py b/scripts/import_cldr.py --- a/scripts/import_cldr.py +++ b/scripts/import_cldr.py @@ -55,7 +55,7 @@ sup = parse(os.path.join(srcdir, 'supplemental', 'supplementalData.xml')) - # import global data from the supplemental files + # Import global data from the supplemental files global_data = {} territory_zones = global_data.setdefault('territory_zones', {}) @@ -69,6 +69,14 @@ for alias in elem.attrib['aliases'].split(): zone_aliases[alias] = tzid + # Import Metazone mapping + meta_zones = global_data.setdefault('meta_zones', {}) + tzsup = parse(os.path.join(srcdir, 'supplemental', 'metazoneInfo.xml')) + for elem in tzsup.findall('//timezone'): + for child in elem.findall('usesMetazone'): + if 'to' not in child.attrib: # FIXME: support old mappings + meta_zones[elem.attrib['type']] = child.attrib['mzone'] + outfile = open(os.path.join(destdir, 'global.dat'), 'wb') try: pickle.dump(global_data, outfile, 2) @@ -197,9 +205,6 @@ info.setdefault('long', {})[child.tag] = unicode(child.text) for child in elem.findall('short/*'): info.setdefault('short', {})[child.tag] = unicode(child.text) - for child in elem.findall('usesMetazone'): - if 'to' not in child.attrib: # FIXME: support old mappings - info['use_metazone'] = child.attrib['mzone'] time_zones[elem.attrib['type']] = info meta_zones = data.setdefault('meta_zones', {})