Register translations
Endpoint: https://api.youcan.shop/translations/{type}/{id}
Method: PUT
Required Scopes
edit-languages
Notes
- Send the
keyanddigestof each translation from thecontentof Get translations. - When a
digestdoes not match the current text in the default language, nothing is saved and you get a 422. Read the item again and translate the new text. - Keys that you leave out keep their translation.
- Texts of the
theme_types are validated like in the theme editor. - You get the item as in Get translations.
Parameters
| Param Name | Param Type | Description | Required |
|---|---|---|---|
| type | string | A translatable type | Yes |
| id | string | The id of an item from the listing | Yes |
| locale | string | The locale of a language from the listing | Yes |
| translations | array | The translations to save | Yes |
| translations.*.key | string | A key from content | Yes |
| translations.*.value | string | The translated text | Yes |
| translations.*.digest | string | The digest of the key from content | Yes |
Request
json
{
"locale": "fr",
"translations": [
{
"key": "product:0b6f1e1e-2f8e-4d7f-9a7d-3f8d3c2a1b00:description",
"value": "<p>Chêne massif.</p>",
"digest": "9d86477bf6bf82bb584f0b869ce2da86a7473ff2896a6b0a13c65ea69888cd12"
}
]
}Response
[422] Unprocessable entity, for a stale digest
json
{
"status": 0,
"detail": "The key is unknown or its source text changed. Read the resource again.",
"meta": {
"fields": {
"translations.0.digest": ["The key is unknown or its source text changed. Read the resource again."]
}
}
}