Skip to main content

Capability Translations

To support multiple languages for each Capability Presentation, create Capability Translations and reference the text in those translations from the Capability Presentation. Here we define English and Korean translation files for our custom elevator Capability.

English (en.json)

{
"tag": "en",
"label": "Custom Garage Door",
"attributes": {
"door": {
"label": "Garage Door Status",
"displayTemplate": "{{attribute}} of {{device.label}} is {{value}}",
"i18n": {
"value": {
"closing": {
"label": "Closing..."
},
"closed": {
"label": "Closed"
},
"opening": {
"label": "Opening..."
},
"partial": {
"label": "Partially open"
},
"open": {
"label": "Open"
}
}
}
}
}
}

Korean (ko.json)

{
"tag": "ko",
"label": "문",
"attributes": {
"door": {
"label": "문",
"displayTemplate": "{{attribute}} {{device.label}}: {{value}}",
"i18n": {
"value": {
"closing": {
"label": "닫는 중…"
},
"closed": {
"label": "닫힘"
},
"opening": {
"label": "여는 중…"
},
"open": {
"label": "열림"
},
"partial": {
"label": "부분적으로 열림"
}
}
}
}
}
}

These files are uploaded using the CLI commands:

smartthings capabilities:translation:upsert perfectlife6617.customGarageDoor -i en.json
smartthings capabilities:translation:upsert perfectlife6617.customGarageDoor -i ko.json

We also need to modify the Capability Presentation to reference the labels using their path in the translation JSON files:

{
"dashboard": {
"states": [
{
"label": "{{door.value}}",
"alternatives": [
{
"key": "closed",
"value": "{{i18n.attributes.door.i18n.value.closed.label}}",
"type": "inactive"
},
{
"key": "open",
"value": "{{i18n.attributes.door.i18n.value.open.label}}",
"type": "active"
},
{
"key": "opening",
"value": "{{i18n.attributes.door.i18n.value.opening.label}}",
"type": "active"
},
{
"key": "closing",
"value": "{{i18n.attributes.door.i18n.value.closing.label}}",
"type": "active"
},
{
"key": "partial",
"value": "{{i18n.attributes.door.i18n.value.partial.label}}",
"type": "active"
},
{
"key": "jammed",
"value": "{{i18n.attributes.door.i18n.value.jammed.label}}",
"type": "active"
}
]
}
],
"actions": [
{
"displayType": "toggleSwitch",
"toggleSwitch": {
"command": {
"name": "setDoor",
"on": "open",
"off": "closed",
"argumentType": "string"
},
"state": {
"value": "door.value",
"on": "open",
"off": "closed",
"valueType": "string"
}
}
}
],
"basicPlus": []
},
"detailView": [
{
"label": "{{i18n.label}}",
"displayType": "list",
"list": {
"command": {
"name": "setDoor",
"alternatives": [
{
"key": "closed",
"value": "{{i18n.attributes.door.i18n.value.closed.label}}",
"type": "inactive"
},
{
"key": "open",
"value": "{{i18n.attributes.door.i18n.value.open.label}}",
"type": "active"
}
],
"argumentType": "string"
},
"state": {
"value": "door.value",
"valueType": "string",
"alternatives": [
{
"key": "closed",
"value": "{{i18n.attributes.door.i18n.value.closed.label}}",
"type": "inactive"
},
{
"key": "open",
"value": "{{i18n.attributes.door.i18n.value.open.label}}",
"type": "active"
},
{
"key": "opening",
"value": "{{i18n.attributes.door.i18n.value.opening.label}}",
"type": "active"
},
{
"key": "closing",
"value": "{{i18n.attributes.door.i18n.value.closing.label}}",
"type": "active"
},
{
"key": "partial",
"value": "{{i18n.attributes.door.i18n.value.partial.label}}",
"type": "active"
},
{
"key": "jammed",
"value": "{{i18n.attributes.door.i18n.value.jammed.label}}",
"type": "active"
}
]
}
},
"state": null
}
],
"automation": {
"conditions": [
{
"label": "{{i18n.label}}",
"displayType": "list",
"list": {
"alternatives": [
{
"key": "closed",
"value": "{{i18n.attributes.door.i18n.value.closed.label}}",
"type": "inactive"
},
{
"key": "open",
"value": "{{i18n.attributes.door.i18n.value.open.label}}",
"type": "active"
},
{
"key": "opening",
"value": "{{i18n.attributes.door.i18n.value.opening.label}}",
"type": "active"
},
{
"key": "closing",
"value": "{{i18n.attributes.door.i18n.value.closing.label}}",
"type": "active"
},
{
"key": "partial",
"value": "{{i18n.attributes.door.i18n.value.partial.label}}",
"type": "active"
},
{
"key": "jammed",
"value": "{{i18n.attributes.door.i18n.value.jammed.label}}",
"type": "active"
}
],
"value": "door.value",
"valueType": "string"
}
}
],
"actions": [
{
"label": "{{i18n.label}}",
"displayType": "list",
"list": {
"alternatives": [
{
"key": "open",
"value": "{{i18n.attributes.door.i18n.value.open.label}}",
"type": "active"
},
{
"key": "closed",
"value": "{{i18n.attributes.door.i18n.value.closed.label}}",
"type": "inactive"
}
]
}
}
]
},
"id": "perfectlife6617.customGarageDoor",
"version": 1
}

The Capability Presentation can be updated with the CLI command:

smartthings capabilities:presentation:update perfectlife6617.customGarageDoor -i presentation.json