From fe89f7c5ac9ba877b7f52baf0c90d1b04852c327 Mon Sep 17 00:00:00 2001 From: Alan Date: Wed, 2 Aug 2017 15:26:32 +0000 Subject: [PATCH] Add level modifiers in JSON This is needed because some layouts don't have an uppercase level. That shouldn't make symbols the 2nd level. --- cldr2json.py | 10 ++++++---- test/data/fr.json | 10 +++++----- 2 files changed, 11 insertions(+), 9 deletions(-) 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 +}