component_metadata: add translation schema (#1934)

This commit is contained in:
Beat Küng
2023-01-04 23:19:59 +01:00
committed by GitHub
parent 0267c4cf9f
commit 74dee05f0c
5 changed files with 225 additions and 2 deletions
+5 -1
View File
@@ -94,7 +94,11 @@
"version": {
"description": "Version number for the format of this file.",
"type": "integer",
"minimum": 1
"minimum": 2
},
"translation": {
"type": "object",
"description": "This needs to match exactly with the content of actuators.translation.json"
},
"show-ui-if": {
"$ref": "#/$defs/condition",
@@ -0,0 +1,94 @@
{
"translation": {
"items": {
"outputs_v1": {
"list": {
"key": "label",
"items": {
"subgroups": {
"list": {
"items": {
"parameters": {
"list": {
"key": "name",
"translate": [ "label" ]
}
},
"per-channel-parameters": {
"list": {
"key": "name",
"translate": [ "label" ]
}
},
"channels": {
"list": {
"key": "param-index",
"translate": [ "label" ]
}
}
}
}
}
}
}
},
"functions_v1": {
"items": {
"*": {
"translate": [ "label" ],
"items": {
"note": {
"translate": [ "text" ]
}
}
}
}
},
"mixer_v1": {
"items": {
"actuator-types": {
"items": {
"*": {
"items": {
"per-item-parameters": {
"list": {
"key": "name",
"translate": [ "label" ]
}
}
}
}
}
},
"config": {
"list": {
"key": "option",
"translate": [ "title" ],
"items": {
"actuators": {
"list": {
"translate": [ "group-label", "item-label-prefix" ],
"items": {
"parameters": {
"list": {
"key": "name",
"translate": [ "label" ]
}
},
"per-item-parameters": {
"list": {
"key": "name",
"translate": [ "label" ]
}
}
}
}
}
}
}
}
}
}
}
}
}
+5 -1
View File
@@ -8,7 +8,11 @@
"version": {
"description": "Version number for the format of this file.",
"type": "integer",
"minimum": 1
"minimum": 2
},
"translation": {
"type": "object",
"description": "This needs to match exactly with the content of parameter.translation.json"
},
"parameters": {
"type": "array",
@@ -0,0 +1,27 @@
{
"translation": {
"items": {
"parameters": {
"list": {
"key": "name",
"translate": [ "shortDesc", "longDesc" ],
"translate-global": ["category", "group"],
"items": {
"bitmask": {
"list": {
"key": "index",
"translate": [ "description" ]
}
},
"values": {
"list": {
"key": "value",
"translate": [ "description" ]
}
}
}
}
}
}
}
}
@@ -0,0 +1,94 @@
{
"$id": "https://mavlink.io/translation.schema.json",
"$schema": "http://json-schema.org/draft-07/schema",
"description": "Schema for translations (*.translation.json)",
"type": "object",
"definitions": {
"items": {
"type": "object",
"patternProperties": {
"^(\\*|[0-9a-zA-Z-_]+)$": {
"comment": "Select individual attributes by name, or use '*' to match all",
"type": "object",
"properties": {
"items": {
"type": "object",
"$ref": "#/definitions/items"
},
"$ref": {
"type": "string",
"comment": "Reference to one of the items in $defs (see below)",
"pattern": "^#/\\$defs/"
},
"translate": {
"type": "array",
"items": {
"type": "string",
"description": "Object attribute to be translated. Might refer to a string or a list of strings."
}
},
"translate-global": {
"description": "Translate globally: this can be used for repeated strings, such as a category, which is then deduplicated and thus needs to be translated only once.",
"type": "array",
"items": {
"type": "string",
"description": "Object attribute to be translated. Might refer to a string or a list of strings."
}
},
"list": {
"type": "object",
"properties": {
"key": {
"type": "string",
"description": "Optionally specify a string/integer attribute that exists in each object of the list and uniquely identifies that object. If possible, specify a key. If not is specified, list indexes will be used (which may cause translation mismatch if elements are added/removed from the list)."
},
"items": {
"type": "object",
"$ref": "#/definitions/items"
},
"translate": {
"type": "array",
"items": {
"type": "string",
"description": "See above."
}
},
"translate-global": {
"type": "array",
"items": {
"type": "string",
"description": "See above."
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
},
"properties": {
"translation": {
"type": "object",
"properties": {
"items": {
"type": "object",
"$ref": "#/definitions/items"
},
"$defs": {
"comment": "Custom references (for recursive definitions). The keys in this dict can be used in a '$ref' as '#/$defs/<key>'",
"$ref": "#/definitions/items"
}
},
"required": [ "items" ],
"additionalProperties": false
}
},
"required": [ "translation" ]
}