diff 0.9.x/scripts/import_cldr.py @ 391:e69a068990f0 stable

Ported [424], [425], and [428] back to 0.9.x branch.
author cmlenz
date Mon, 14 Jul 2008 19:46:19 +0000
parents 6a0e7205790f
children 40735021c908
line wrap: on
line diff
--- a/0.9.x/scripts/import_cldr.py
+++ b/0.9.x/scripts/import_cldr.py
@@ -137,13 +137,11 @@
     filenames.insert(0, 'root.xml')
 
     for filename in filenames:
-        print>>sys.stderr, 'Processing input file %r' % filename
         stem, ext = os.path.splitext(filename)
         if ext != '.xml':
             continue
-        #if stem != 'root':
-        #    break
 
+        print>>sys.stderr, 'Processing input file %r' % filename
         tree = parse(os.path.join(srcdir, 'main', filename))
         data = {}
 
@@ -442,12 +440,18 @@
         currency_names = data.setdefault('currency_names', {})
         currency_symbols = data.setdefault('currency_symbols', {})
         for elem in tree.findall('//currencies/currency'):
-            name = elem.findtext('displayName')
-            if name:
-                currency_names[elem.attrib['type']] = unicode(name)
-            symbol = elem.findtext('symbol')
-            if symbol:
-                currency_symbols[elem.attrib['type']] = unicode(symbol)
+            code = elem.attrib['type']
+            # TODO: support plural rules for currency name selection
+            for name in elem.findall('displayName'):
+                if ('draft' in name.attrib or 'count' in name.attrib) \
+                        and code in currency_names:
+                    continue
+                currency_names[code] = unicode(name.text)
+            # TODO: support choice patterns for currency symbol selection
+            symbol = elem.find('symbol')
+            if symbol is not None and 'draft' not in symbol.attrib \
+                    and 'choice' not in symbol.attrib:
+                currency_symbols[code] = unicode(symbol.text)
 
         outfile = open(os.path.join(destdir, 'localedata', stem + '.dat'), 'wb')
         try:
Copyright (C) 2012-2017 Edgewall Software