changeset 345:e818b03b370f trunk

Update to CLDR 1.5.1, which split out the metazone mappings into a separate supplemental file.
author cmlenz
date Mon, 16 Jun 2008 12:24:04 +0000
parents eb12741b65df
children 76bfb34282af
files ChangeLog babel/dates.py scripts/import_cldr.py
diffstat 3 files changed, 31 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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
--- 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', {})
Copyright (C) 2012-2017 Edgewall Software