summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAarni Koskela <akx@iki.fi>2016-11-21 16:39:53 +0200
committerAarni Koskela <akx@iki.fi>2018-01-17 09:14:18 +0200
commit77849ec967f9ff6f8470753abc2976c94b22aa2e (patch)
tree8b2bd1fe1f0b957e5202b278790764d089bd1913
parent63741104da581fbed53ad854d00835cf5f87a8d6 (diff)
downloadbabel-77849ec967f9ff6f8470753abc2976c94b22aa2e.tar.gz
cldr: Parse compact decimal formats that appear in CLDR 30
-rwxr-xr-xscripts/import_cldr.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/scripts/import_cldr.py b/scripts/import_cldr.py
index 4f49491..94fe85e 100755
--- a/scripts/import_cldr.py
+++ b/scripts/import_cldr.py
@@ -717,7 +717,19 @@ def parse_decimal_formats(data, tree):
for pattern_el in elem.findall('./decimalFormat/pattern'):
pattern_type = pattern_el.attrib.get('type')
pattern = numbers.parse_pattern(text_type(pattern_el.text))
- if not pattern_type:
+ if pattern_type:
+ # This is a compact decimal format, see:
+ # http://www.unicode.org/reports/tr35/tr35-45/tr35-numbers.html#Compact_Number_Formats
+
+ # These are mapped into a `compact_decimal_formats` dictionary
+ # with the format {length: {count: {multiplier: pattern}}}.
+
+ # TODO: Add support for formatting them.
+ compact_decimal_formats = data.setdefault('compact_decimal_formats', {})
+ length_map = compact_decimal_formats.setdefault(length_type, {})
+ length_count_map = length_map.setdefault(pattern_el.attrib['count'], {})
+ length_count_map[pattern_type] = pattern
+ else:
# Regular decimal format.
decimal_formats[length_type] = pattern