# Internationalization
You can create multilingual plugins whose interface changes depending on the user interface language.
To do this, when setting plugin elements, a special directive { "@t": "someKey" }
is used, where someKey
is the key of the translation string. When the plugin is activated, all directives of this kind are replaced by the value corresponding to the user's language from the locale
block.
First, the locale
block in the current plugin entity is used. If there is a corresponding key in this object of user's current language, then instead of { "@t": "someKey" }
the found value is substituted. If the key is not present, then the translation is searched at the level above - in the main plugin file (index.json
).
For example:
{
"type": "destination",
"name": "my-destination",
"title": { "@t": "title" },
"icon": null,
"content": {
"additionalProps": [
{
"name": "myPrice",
"title": { "@t": "priceField" },
"type": "integer"
}
]
},
"locale": {
"en": {
"title": "My microstock",
"priceField": "Price"
},
"ru": {
"title": "Мой микросток",
"priceField": "Цена"
}
}
}
After processing, if the current language is Russian, it turns into
{
"type": "destination",
"name": "my-destination",
"title": "Мой микросток",
"icon": null,
"content": {
"additionalProps": [
{
"name": "myPrice",
"title": "Цена",
"type": "integer"
}
]
},
"locale": {
// ...
}
}
When changing the language, the plugins are first deactivated and then activated again with the new selected interface language