diff --git a/cldr2json.py b/cldr2json.py index 1a2574698..0d4fcc6d5 100755 --- a/cldr2json.py +++ b/cldr2json.py @@ -97,19 +97,21 @@ def convert_xml(tree): root["levels"] = [] # parse levels for index, keymap in enumerate(tree.iter('keyMap')): - level = {} - root["levels"].append(level) - level["level"] = index + 1 # FIXME: heuristics here modifiers = keymap.get('modifiers') if not modifiers: mode = 'default' - elif 'shift' in modifiers.split(' ') or 'lock' in modifiers.split(' '): + modifiers = '' + elif 'shift' in modifiers.split(' '): mode = 'latched' + modifiers = 'shift' else: mode = 'locked' + level = {} + level["level"] = modifiers level["mode"] = mode level["rows"] = parse_rows(keymap) + root["levels"].append(level) return root diff --git a/test/data/fr.json b/test/data/fr.json index 2aeb67479..3a8949fe1 100644 --- a/test/data/fr.json +++ b/test/data/fr.json @@ -1,7 +1,7 @@ { "levels": [ { - "level": 1, + "level": "", "mode": "default", "rows": [ [ @@ -163,7 +163,7 @@ ] }, { - "level": 2, + "level": "shift", "mode": "latched", "rows": [ [ @@ -325,7 +325,7 @@ ] }, { - "level": 3, + "level": "opt", "mode": "locked", "rows": [ [ @@ -478,7 +478,7 @@ ] }, { - "level": 4, + "level": "opt+shift", "mode": "locked", "rows": [ [ @@ -611,4 +611,4 @@ ], "locale": "fr", "name": "French" -} \ No newline at end of file +}