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.
This commit is contained in:
parent
8b3be5e063
commit
fe89f7c5ac
10
cldr2json.py
10
cldr2json.py
@ -97,19 +97,21 @@ def convert_xml(tree):
|
|||||||
root["levels"] = []
|
root["levels"] = []
|
||||||
# parse levels
|
# parse levels
|
||||||
for index, keymap in enumerate(tree.iter('keyMap')):
|
for index, keymap in enumerate(tree.iter('keyMap')):
|
||||||
level = {}
|
|
||||||
root["levels"].append(level)
|
|
||||||
level["level"] = index + 1
|
|
||||||
# FIXME: heuristics here
|
# FIXME: heuristics here
|
||||||
modifiers = keymap.get('modifiers')
|
modifiers = keymap.get('modifiers')
|
||||||
if not modifiers:
|
if not modifiers:
|
||||||
mode = 'default'
|
mode = 'default'
|
||||||
elif 'shift' in modifiers.split(' ') or 'lock' in modifiers.split(' '):
|
modifiers = ''
|
||||||
|
elif 'shift' in modifiers.split(' '):
|
||||||
mode = 'latched'
|
mode = 'latched'
|
||||||
|
modifiers = 'shift'
|
||||||
else:
|
else:
|
||||||
mode = 'locked'
|
mode = 'locked'
|
||||||
|
level = {}
|
||||||
|
level["level"] = modifiers
|
||||||
level["mode"] = mode
|
level["mode"] = mode
|
||||||
level["rows"] = parse_rows(keymap)
|
level["rows"] = parse_rows(keymap)
|
||||||
|
root["levels"].append(level)
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"levels": [
|
"levels": [
|
||||||
{
|
{
|
||||||
"level": 1,
|
"level": "",
|
||||||
"mode": "default",
|
"mode": "default",
|
||||||
"rows": [
|
"rows": [
|
||||||
[
|
[
|
||||||
@ -163,7 +163,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"level": 2,
|
"level": "shift",
|
||||||
"mode": "latched",
|
"mode": "latched",
|
||||||
"rows": [
|
"rows": [
|
||||||
[
|
[
|
||||||
@ -325,7 +325,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"level": 3,
|
"level": "opt",
|
||||||
"mode": "locked",
|
"mode": "locked",
|
||||||
"rows": [
|
"rows": [
|
||||||
[
|
[
|
||||||
@ -478,7 +478,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"level": 4,
|
"level": "opt+shift",
|
||||||
"mode": "locked",
|
"mode": "locked",
|
||||||
"rows": [
|
"rows": [
|
||||||
[
|
[
|
||||||
|
Loading…
Reference in New Issue
Block a user